Flutter Engine
The Flutter Engine
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
ui Namespace Reference

Namespaces

namespace  win
 

Classes

struct  AXActionData
 
class  AXActionHandler
 
class  AXActionHandlerBase
 
class  AXEventGenerator
 
struct  AXEventIntent
 
class  AXFragmentRootDelegateWin
 
class  AXFragmentRootMapWin
 
class  AXFragmentRootPlatformNodeWin
 
class  AXFragmentRootTest
 
class  AXFragmentRootWin
 
struct  AXHypertext
 
class  AXMode
 
class  AXModeObserver
 
class  AXNode
 
struct  AXNodeData
 
class  AXNodePosition
 
struct  AXNodeTextStyles
 
class  AXPlatformNode
 
class  AXPlatformNodeBase
 
class  AXPlatformNodeDelegate
 
class  AXPlatformNodeDelegateBase
 
class  AXPlatformNodeMac
 
class  AXPlatformNodeMacTest
 
class  AXPlatformNodeTest
 
class  AXPlatformNodeTextProviderTest
 
class  AXPlatformNodeTextRangeProviderTest
 
class  AXPlatformNodeWinTest
 
class  AXPlatformRelationWin
 
class  AXPlatformTreeManager
 
class  AXPosition
 
class  AXRange
 
class  AXRangePhysicalPixelRectDelegate
 
class  AXRangeRectDelegate
 
struct  AXRelativeBounds
 
class  AXTableInfo
 
class  AXTableInfoTest
 
class  AXTestSmallBankUniqueId
 
class  AXTree
 
struct  AXTreeData
 
class  AXTreeID
 
struct  AXTreeIDHash
 
class  AXTreeIDRegistry
 
class  AXTreeManager
 
class  AXTreeManagerMap
 
class  AXTreeObserver
 
struct  AXTreeUpdateBase
 
struct  AXTreeUpdateState
 
class  AXUniqueId
 
class  MockAXPlatformNodeTextRangeProviderWin
 
class  MockIRawElementProviderSimple
 
struct  PendingStructureChanges
 
class  ScopedAXEmbeddedObjectBehaviorSetter
 
class  TestAXNodeHelper
 
class  TestAXNodeWrapper
 
class  TestAXTreeManager
 
class  TestFragmentRootDelegate
 
class  UiaRegistrarWin
 

Typedefs

using TestPositionType = std::unique_ptr< AXPosition< AXNodePosition, AXNode > >
 
using TestPositionRange = AXRange< AXPosition< AXNodePosition, AXNode > >
 
using TestPositionInstance = std::unique_ptr< AXPosition< AXNodePosition, AXNode > >
 
using AXTreeUpdate = AXTreeUpdateBase< AXNodeData, AXTreeData >
 
using UniqueIdMap = std::unordered_map< int32_t, AXPlatformNode * >
 
using TextAttribute = std::pair< std::string, std::string >
 
using TextAttributeList = std::vector< TextAttribute >
 
using TextAttributeMap = std::map< int, TextAttributeList >
 

Enumerations

enum class  AXClippingBehavior { kUnclipped , kClipped }
 
enum class  AXCoordinateSystem { kScreenPhysicalPixels , kScreenDIPs , kRootFrame , kFrame }
 
enum class  AXOffscreenResult { kOnscreen , kOffscreen }
 
enum class  AXPositionKind { NULL_POSITION , TREE_POSITION , TEXT_POSITION }
 
enum class  AXBoundaryBehavior { CrossBoundary , StopAtAnchorBoundary , StopIfAlreadyAtBoundary , StopAtLastAnchorBoundary }
 
enum class  AXBoundaryType { kNone , kUnitBoundary , kDocumentStart , kDocumentEnd }
 
enum class  AXPositionAdjustmentBehavior { kMoveBackward , kMoveForward }
 
enum class  AXRangeExpandBehavior { kLeftFirst , kRightFirst }
 
enum class  AXEmbeddedObjectBehavior { kExposeCharacter , kSuppressCharacter }
 
enum class  AXTextConcatenationBehavior { kAsInnerText , kAsTextContent }
 
enum class  AXTreePendingStructureStatus { kNotStarted , kComputing , kComplete , kFailed }
 

Functions

std::optional< int32_t > GetActivePopupAxUniqueId ()
 
void SetActivePopupAxUniqueId (std::optional< int32_t > ax_unique_id)
 
void ClearActivePopupAxUniqueId ()
 
const char * ToString (ax::mojom::Event event)
 
ax::mojom::Event ParseEvent (const char *event)
 
const char * ToString (ax::mojom::Role role)
 
ax::mojom::Role ParseRole (const char *role)
 
const char * ToString (ax::mojom::State state)
 
ax::mojom::State ParseState (const char *state)
 
const char * ToString (ax::mojom::Action action)
 
ax::mojom::Action ParseAction (const char *action)
 
const char * ToString (ax::mojom::ActionFlags action_flags)
 
ax::mojom::ActionFlags ParseActionFlags (const char *action_flags)
 
const char * ToString (ax::mojom::ScrollAlignment scroll_alignment)
 
ax::mojom::ScrollAlignment ParseScrollAlignment (const char *scroll_alignment)
 
const char * ToString (ax::mojom::DefaultActionVerb default_action_verb)
 
ax::mojom::DefaultActionVerb ParseDefaultActionVerb (const char *default_action_verb)
 
const char * ToString (ax::mojom::Mutation mutation)
 
ax::mojom::Mutation ParseMutation (const char *mutation)
 
const char * ToString (ax::mojom::StringAttribute string_attribute)
 
ax::mojom::StringAttribute ParseStringAttribute (const char *string_attribute)
 
const char * ToString (ax::mojom::IntAttribute int_attribute)
 
ax::mojom::IntAttribute ParseIntAttribute (const char *int_attribute)
 
const char * ToString (ax::mojom::FloatAttribute float_attribute)
 
ax::mojom::FloatAttribute ParseFloatAttribute (const char *float_attribute)
 
const char * ToString (ax::mojom::BoolAttribute bool_attribute)
 
ax::mojom::BoolAttribute ParseBoolAttribute (const char *bool_attribute)
 
const char * ToString (ax::mojom::IntListAttribute int_list_attribute)
 
ax::mojom::IntListAttribute ParseIntListAttribute (const char *int_list_attribute)
 
const char * ToString (ax::mojom::StringListAttribute string_list_attribute)
 
ax::mojom::StringListAttribute ParseStringListAttribute (const char *string_list_attribute)
 
const char * ToString (ax::mojom::ListStyle list_style)
 
ax::mojom::ListStyle ParseListStyle (const char *list_style)
 
const char * ToString (ax::mojom::MarkerType marker_type)
 
ax::mojom::MarkerType ParseMarkerType (const char *marker_type)
 
const char * ToString (ax::mojom::MoveDirection move_direction)
 
ax::mojom::MoveDirection ParseMoveDirection (const char *move_direction)
 
const char * ToString (ax::mojom::Command command)
 
ax::mojom::Command ParseCommand (const char *command)
 
const char * ToString (ax::mojom::TextBoundary text_boundary)
 
ax::mojom::TextBoundary ParseTextBoundary (const char *text_boundary)
 
const char * ToString (ax::mojom::TextDecorationStyle text_decoration_style)
 
ax::mojom::TextDecorationStyle ParseTextDecorationStyle (const char *text_decoration_style)
 
const char * ToString (ax::mojom::TextAlign text_align)
 
ax::mojom::TextAlign ParseTextAlign (const char *text_align)
 
const char * ToString (ax::mojom::WritingDirection text_direction)
 
ax::mojom::WritingDirection ParseTextDirection (const char *text_direction)
 
const char * ToString (ax::mojom::TextPosition text_position)
 
ax::mojom::TextPosition ParseTextPosition (const char *text_position)
 
const char * ToString (ax::mojom::TextStyle text_style)
 
ax::mojom::TextStyle ParseTextStyle (const char *text_style)
 
const char * ToString (ax::mojom::AriaCurrentState aria_current_state)
 
ax::mojom::AriaCurrentState ParseAriaCurrentState (const char *aria_current_state)
 
const char * ToString (ax::mojom::HasPopup has_popup)
 
ax::mojom::HasPopup ParseHasPopup (const char *has_popup)
 
const char * ToString (ax::mojom::InvalidState invalid_state)
 
ax::mojom::InvalidState ParseInvalidState (const char *invalid_state)
 
const char * ToString (ax::mojom::Restriction restriction)
 
ax::mojom::Restriction ParseRestriction (const char *restriction)
 
const char * ToString (ax::mojom::CheckedState checked_state)
 
ax::mojom::CheckedState ParseCheckedState (const char *checked_state)
 
const char * ToString (ax::mojom::SortDirection sort_direction)
 
ax::mojom::SortDirection ParseSortDirection (const char *sort_direction)
 
const char * ToString (ax::mojom::NameFrom name_from)
 
ax::mojom::NameFrom ParseNameFrom (const char *name_from)
 
const char * ToString (ax::mojom::DescriptionFrom description_from)
 
ax::mojom::DescriptionFrom ParseDescriptionFrom (const char *description_from)
 
const char * ToString (ax::mojom::EventFrom event_from)
 
ax::mojom::EventFrom ParseEventFrom (const char *event_from)
 
const char * ToString (ax::mojom::Gesture gesture)
 
ax::mojom::Gesture ParseGesture (const char *gesture)
 
const char * ToString (ax::mojom::TextAffinity text_affinity)
 
ax::mojom::TextAffinity ParseTextAffinity (const char *text_affinity)
 
const char * ToString (ax::mojom::TreeOrder tree_order)
 
ax::mojom::TreeOrder ParseTreeOrder (const char *tree_order)
 
const char * ToString (ax::mojom::ImageAnnotationStatus status)
 
ax::mojom::ImageAnnotationStatus ParseImageAnnotationStatus (const char *status)
 
const char * ToString (ax::mojom::Dropeffect dropeffect)
 
ax::mojom::Dropeffect ParseDropeffect (const char *dropeffect)
 
AX_BASE_EXPORT std::string ToLocalizedString (ax::mojom::DefaultActionVerb action_verb)
 
template<typename T >
void TestEnumStringConversion (T(ParseFunction)(const char *), int32_t(step)(int32_t)=[](int32_t val) { return val+1;})
 
template<typename T , typename U >
void TestAXNodeDataSetter (void(AXNodeData::*Setter)(T, const U &), const U &value)
 
template<typename T , typename U >
void TestAXNodeDataSetter (void(AXNodeData::*Setter)(T, U), U value)
 
 TEST (AXEnumUtilTest, Event)
 
 TEST (AXEnumUtilTest, Role)
 
 TEST (AXEnumUtilTest, State)
 
 TEST (AXEnumUtilTest, Action)
 
 TEST (AXEnumUtilTest, ActionFlags)
 
 TEST (AXEnumUtilTest, DefaultActionVerb)
 
 TEST (AXEnumUtilTest, Mutation)
 
 TEST (AXEnumUtilTest, StringAttribute)
 
 TEST (AXEnumUtilTest, IntAttribute)
 
 TEST (AXEnumUtilTest, FloatAttribute)
 
 TEST (AXEnumUtilTest, BoolAttribute)
 
 TEST (AXEnumUtilTest, IntListAttribute)
 
 TEST (AXEnumUtilTest, StringListAttribute)
 
 TEST (AXEnumUtilTest, MarkerType)
 
 TEST (AXEnumUtilTest, Text_Decoration_Style)
 
 TEST (AXEnumUtilTest, ListStyle)
 
 TEST (AXEnumUtilTest, MoveDirection)
 
 TEST (AXEnumUtilTest, Command)
 
 TEST (AXEnumUtilTest, TextAlign)
 
 TEST (AXEnumUtilTest, TextBoundary)
 
 TEST (AXEnumUtilTest, TextDirection)
 
 TEST (AXEnumUtilTest, TextPosition)
 
 TEST (AXEnumUtilTest, TextStyle)
 
 TEST (AXEnumUtilTest, AriaCurrentState)
 
 TEST (AXEnumUtilTest, HasPopup)
 
 TEST (AXEnumUtilTest, InvalidState)
 
 TEST (AXEnumUtilTest, Restriction)
 
 TEST (AXEnumUtilTest, CheckedState)
 
 TEST (AXEnumUtilTest, SortDirection)
 
 TEST (AXEnumUtilTest, NameFrom)
 
 TEST (AXEnumUtilTest, DescriptionFrom)
 
 TEST (AXEnumUtilTest, EventFrom)
 
 TEST (AXEnumUtilTest, Gesture)
 
 TEST (AXEnumUtilTest, TextAffinity)
 
 TEST (AXEnumUtilTest, TreeOrder)
 
 TEST (AXEnumUtilTest, ImageAnnotationStatus)
 
 TEST (AXEnumUtilTest, Dropeffect)
 
std::ostream & operator<< (std::ostream &os, AXEventGenerator::Event event)
 
const char * ToString (AXEventGenerator::Event event)
 
 TEST (AXEventGeneratorTest, LoadCompleteSameTree)
 
 TEST (AXEventGeneratorTest, LoadCompleteNewTree)
 
 TEST (AXEventGeneratorTest, LoadStart)
 
 TEST (AXEventGeneratorTest, DocumentSelectionChanged)
 
 TEST (AXEventGeneratorTest, DocumentTitleChanged)
 
 TEST (AXEventGeneratorTest, FocusIdUnchanged)
 
 TEST (AXEventGeneratorTest, FocusIdChanged)
 
 TEST (AXEventGeneratorTest, ExpandedAndRowCount)
 
 TEST (AXEventGeneratorTest, SelectedAndSelectedChildren)
 
 TEST (AXEventGeneratorTest, StringValueChanged)
 
 TEST (AXEventGeneratorTest, FloatValueChanged)
 
 TEST (AXEventGeneratorTest, InvalidStatusChanged)
 
 TEST (AXEventGeneratorTest, AddLiveRegionAttribute)
 
 TEST (AXEventGeneratorTest, CheckedStateChanged)
 
 TEST (AXEventGeneratorTest, ActiveDescendantChanged)
 
 TEST (AXEventGeneratorTest, CreateAlertAndLiveRegion)
 
 TEST (AXEventGeneratorTest, LiveRegionChanged)
 
 TEST (AXEventGeneratorTest, LiveRegionOnlyTextChanges)
 
 TEST (AXEventGeneratorTest, BusyLiveRegionChanged)
 
 TEST (AXEventGeneratorTest, AddChild)
 
 TEST (AXEventGeneratorTest, RemoveChild)
 
 TEST (AXEventGeneratorTest, ReorderChildren)
 
 TEST (AXEventGeneratorTest, ScrollHorizontalPositionChanged)
 
 TEST (AXEventGeneratorTest, ScrollVerticalPositionChanged)
 
 TEST (AXEventGeneratorTest, TextAttributeChanged)
 
 TEST (AXEventGeneratorTest, ObjectAttributeChanged)
 
 TEST (AXEventGeneratorTest, OtherAttributeChanged)
 
 TEST (AXEventGeneratorTest, NameChanged)
 
 TEST (AXEventGeneratorTest, DescriptionChanged)
 
 TEST (AXEventGeneratorTest, RoleChanged)
 
 TEST (AXEventGeneratorTest, MenuItemSelected)
 
 TEST (AXEventGeneratorTest, NodeBecomesIgnored)
 
 TEST (AXEventGeneratorTest, NodeBecomesIgnored2)
 
 TEST (AXEventGeneratorTest, NodeBecomesUnignored)
 
 TEST (AXEventGeneratorTest, NodeBecomesUnignored2)
 
 TEST (AXEventGeneratorTest, SubtreeBecomesUnignored)
 
 TEST (AXEventGeneratorTest, TwoNodesSwapIgnored)
 
 TEST (AXEventGeneratorTest, TwoNodesSwapIgnored2)
 
 TEST (AXEventGeneratorTest, IgnoredChangedFiredOnAncestorOnly1)
 
 TEST (AXEventGeneratorTest, IgnoredChangedFiredOnAncestorOnly2)
 
 TEST (AXEventGeneratorTest, IgnoredChangedFiredOnAncestorOnly3)
 
 TEST (AXEventGeneratorTest, IgnoredChangedFiredOnAncestorOnly4)
 
 TEST (AXEventGeneratorTest, IgnoredChangedFiredOnAncestorOnly5)
 
 TEST (AXEventGeneratorTest, IgnoredChangedFiredOnAncestorOnly6)
 
 TEST (AXEventGeneratorTest, IgnoredChangedFiredOnAncestorOnly7)
 
 TEST (AXEventGeneratorTest, IgnoredChangedFiredOnAncestorOnly8)
 
 TEST (AXEventGeneratorTest, ActiveDescendantChangeOnDescendant)
 
 TEST (AXEventGeneratorTest, ImageAnnotationChanged)
 
 TEST (AXEventGeneratorTest, ImageAnnotationStatusChanged)
 
 TEST (AXEventGeneratorTest, StringPropertyChanges)
 
 TEST (AXEventGeneratorTest, IntPropertyChanges)
 
 TEST (AXEventGeneratorTest, IntListPropertyChanges)
 
 TEST (AXEventGeneratorTest, AriaBusyChanged)
 
 TEST (AXEventGeneratorTest, MultiselectableStateChanged)
 
 TEST (AXEventGeneratorTest, RequiredStateChanged)
 
 TEST (AXEventGeneratorTest, FlowToChanged)
 
 TEST (AXEventGeneratorTest, ControlsChanged)
 
 TEST (AXEventGeneratorTest, AtomicChanged)
 
 TEST (AXEventGeneratorTest, DropeffectChanged)
 
 TEST (AXEventGeneratorTest, GrabbedChanged)
 
 TEST (AXEventGeneratorTest, HasPopupChanged)
 
 TEST (AXEventGeneratorTest, LiveRelevantChanged)
 
 TEST (AXEventGeneratorTest, MultilineStateChanged)
 
bool operator== (const AXEventIntent &a, const AXEventIntent &b)
 
bool operator!= (const AXEventIntent &a, const AXEventIntent &b)
 
std::ostream & operator<< (std::ostream &stream, const AXMode &mode)
 
static constexpr AXMode kAXModeWebContentsOnly (AXMode::kWebContents|AXMode::kInlineTextBoxes|AXMode::kScreenReader|AXMode::kHTML)
 
static constexpr AXMode kAXModeComplete (AXMode::kNativeAPIs|AXMode::kWebContents|AXMode::kInlineTextBoxes|AXMode::kScreenReader|AXMode::kHTML)
 
std::ostream & operator<< (std::ostream &stream, const AXNode &node)
 
bool IsNodeIdIntAttribute (ax::mojom::IntAttribute attr)
 
bool IsNodeIdIntListAttribute (ax::mojom::IntListAttribute attr)
 
 TEST (AXNodeDataTest, GetAndSetCheckedState)
 
 TEST (AXNodeDataTest, TextAttributes)
 
 TEST (AXNodeDataTest, IsButtonPressed)
 
 TEST (AXNodeDataTest, IsClickable)
 
 TEST (AXNodeDataTest, IsInvocable)
 
 TEST (AXNodeDataTest, IsMenuButton)
 
 TEST (AXNodeDataTest, SupportsExpandCollapse)
 
 TEST (AXNodeDataTest, BitFieldsSanityCheck)
 
 TEST_F (AXPositionTest, Clone)
 
 TEST_F (AXPositionTest, Serialize)
 
 TEST_F (AXPositionTest, ToString)
 
 TEST_F (AXPositionTest, IsIgnored)
 
 TEST_F (AXPositionTest, GetTextFromNullPosition)
 
 TEST_F (AXPositionTest, GetTextFromRoot)
 
 TEST_F (AXPositionTest, GetTextFromButton)
 
 TEST_F (AXPositionTest, GetTextFromCheckbox)
 
 TEST_F (AXPositionTest, GetTextFromTextField)
 
 TEST_F (AXPositionTest, GetTextFromStaticText)
 
 TEST_F (AXPositionTest, GetTextFromInlineTextBox)
 
 TEST_F (AXPositionTest, GetTextFromLineBreak)
 
 TEST_F (AXPositionTest, GetMaxTextOffsetFromNullPosition)
 
 TEST_F (AXPositionTest, GetMaxTextOffsetFromRoot)
 
 TEST_F (AXPositionTest, GetMaxTextOffsetFromButton)
 
 TEST_F (AXPositionTest, GetMaxTextOffsetFromCheckbox)
 
 TEST_F (AXPositionTest, GetMaxTextOffsetFromTextfield)
 
 TEST_F (AXPositionTest, GetMaxTextOffsetFromStaticText)
 
 TEST_F (AXPositionTest, GetMaxTextOffsetFromInlineTextBox)
 
 TEST_F (AXPositionTest, GetMaxTextOffsetFromLineBreak)
 
 TEST_F (AXPositionTest, GetMaxTextOffsetUpdate)
 
 TEST_F (AXPositionTest, GetMaxTextOffsetAndGetTextWithGeneratedContent)
 
 TEST_F (AXPositionTest, AtStartOfAnchorWithNullPosition)
 
 TEST_F (AXPositionTest, AtStartOfAnchorWithTreePosition)
 
 TEST_F (AXPositionTest, AtStartOfAnchorWithTextPosition)
 
 TEST_F (AXPositionTest, AtEndOfAnchorWithNullPosition)
 
 TEST_F (AXPositionTest, AtEndOfAnchorWithTreePosition)
 
 TEST_F (AXPositionTest, AtEndOfAnchorWithTextPosition)
 
 TEST_F (AXPositionTest, AtStartOfLineWithTextPosition)
 
 TEST_F (AXPositionTest, AtStartOfLineStaticTextExtraPrecedingSpace)
 
 TEST_F (AXPositionTest, AtEndOfLineWithTextPosition)
 
 TEST_F (AXPositionTest, AtStartOfBlankLine)
 
 TEST_F (AXPositionTest, AtEndOfBlankLine)
 
 TEST_F (AXPositionTest, AtStartAndEndOfLineWhenAtEndOfTextSpan)
 
 TEST_F (AXPositionTest, AtStartAndEndOfLineInsideTextField)
 
 TEST_F (AXPositionTest, AtStartOfParagraphWithTextPosition)
 
 TEST_F (AXPositionTest, AtEndOfParagraphWithTextPosition)
 
 TEST_F (AXPositionTest, ParagraphEdgesWithPreservedNewLine)
 
 TEST_F (AXPositionTest, PreviousParagraphEndStopAtAnchorBoundaryWithConsecutiveParentChildLineBreakingObjects)
 
 TEST_F (AXPositionTest, AtStartOrEndOfParagraphOnAListMarker)
 
 TEST_F (AXPositionTest, AtStartOrEndOfParagraphWithLeadingAndTrailingDocumentWhitespace)
 
 TEST_F (AXPositionTest, AtStartOrEndOfParagraphWithIgnoredNodes)
 
 TEST_F (AXPositionTest, AtStartOrEndOfParagraphWithEmbeddedObjectCharacter)
 
 TEST_F (AXPositionTest, LowestCommonAncestor)
 
 TEST_F (AXPositionTest, AsTreePositionWithNullPosition)
 
 TEST_F (AXPositionTest, AsTreePositionWithTreePosition)
 
 TEST_F (AXPositionTest, AsTreePositionWithTextPosition)
 
 TEST_F (AXPositionTest, AsTextPositionWithNullPosition)
 
 TEST_F (AXPositionTest, AsTextPositionWithTreePosition)
 
 TEST_F (AXPositionTest, AsTextPositionWithTextPosition)
 
 TEST_F (AXPositionTest, AsLeafTreePositionWithNullPosition)
 
 TEST_F (AXPositionTest, AsLeafTreePositionWithTreePosition)
 
 TEST_F (AXPositionTest, AsLeafTreePositionWithTextPosition)
 
 TEST_F (AXPositionTest, AsLeafTextPositionWithNullPosition)
 
 TEST_F (AXPositionTest, AsLeafTextPositionWithTreePosition)
 
 TEST_F (AXPositionTest, AsLeafTextPositionWithTextPosition)
 
 TEST_F (AXPositionTest, AsLeafTextPositionWithTextPositionAndEmptyTextSandwich)
 
 TEST_F (AXPositionTest, AsUnignoredPosition)
 
 TEST_F (AXPositionTest, CreatePositionAtTextBoundaryDocumentStartEndIsIgnored)
 
 TEST_F (AXPositionTest, CreatePositionAtInvalidGraphemeBoundary)
 
 TEST_F (AXPositionTest, CreatePositionAtStartOfAnchorWithNullPosition)
 
 TEST_F (AXPositionTest, CreatePositionAtStartOfAnchorWithTreePosition)
 
 TEST_F (AXPositionTest, CreatePositionAtStartOfAnchorWithTextPosition)
 
 TEST_F (AXPositionTest, CreatePositionAtEndOfAnchorWithNullPosition)
 
 TEST_F (AXPositionTest, CreatePositionAtEndOfAnchorWithTreePosition)
 
 TEST_F (AXPositionTest, CreatePositionAtEndOfAnchorWithTextPosition)
 
 TEST_F (AXPositionTest, CreatePositionAtPreviousFormatStartWithNullPosition)
 
 TEST_F (AXPositionTest, CreatePositionAtPreviousFormatStartWithTreePosition)
 
 TEST_F (AXPositionTest, CreatePositionAtPreviousFormatStartWithTextPosition)
 
 TEST_F (AXPositionTest, CreatePositionAtNextFormatEndWithNullPosition)
 
 TEST_F (AXPositionTest, CreatePositionAtNextFormatEndWithTreePosition)
 
 TEST_F (AXPositionTest, CreatePositionAtNextFormatEndWithTextPosition)
 
 TEST_F (AXPositionTest, CreatePositionAtFormatBoundaryWithTextPosition)
 
 TEST_F (AXPositionTest, MoveByFormatWithIgnoredNodes)
 
 TEST_F (AXPositionTest, CreatePositionAtPageBoundaryWithTextPosition)
 
 TEST_F (AXPositionTest, CreatePositionAtPageBoundaryWithTreePosition)
 
 TEST_F (AXPositionTest, CreatePagePositionWithNullPosition)
 
 TEST_F (AXPositionTest, CreatePositionAtStartOfDocumentWithNullPosition)
 
 TEST_F (AXPositionTest, CreatePagePositionWithNonPaginatedDocument)
 
 TEST_F (AXPositionTest, CreatePositionAtStartOfDocumentWithTreePosition)
 
 TEST_F (AXPositionTest, CreatePositionAtStartOfDocumentWithTextPosition)
 
 TEST_F (AXPositionTest, CreatePositionAtEndOfDocumentWithNullPosition)
 
 TEST_F (AXPositionTest, CreatePositionAtEndOfDocumentWithTreePosition)
 
 TEST_F (AXPositionTest, CreatePositionAtEndOfDocumentWithTextPosition)
 
 TEST_F (AXPositionTest, AtLastNodeInTree)
 
 TEST_F (AXPositionTest, CreateChildPositionAtWithNullPosition)
 
 TEST_F (AXPositionTest, CreateChildPositionAtWithTreePosition)
 
 TEST_F (AXPositionTest, CreateChildPositionAtWithTextPosition)
 
 TEST_F (AXPositionTest, CreateParentPositionWithNullPosition)
 
 TEST_F (AXPositionTest, CreateParentPositionWithTreePosition)
 
 TEST_F (AXPositionTest, CreateParentPositionWithTextPosition)
 
 TEST_F (AXPositionTest, CreateNextAndPreviousLeafTextPositionWithNullPosition)
 
 TEST_F (AXPositionTest, CreateNextLeafTextPosition)
 
 TEST_F (AXPositionTest, CreatePreviousLeafTextPosition)
 
 TEST_F (AXPositionTest, CreateNextLeafTreePosition)
 
 TEST_F (AXPositionTest, CreatePreviousLeafTreePosition)
 
 TEST_F (AXPositionTest, AsLeafTextPositionBeforeAndAfterCharacterWithNullPosition)
 
 TEST_F (AXPositionTest, AsLeafTextPositionBeforeAndAfterCharacterAtInvalidGraphemeBoundary)
 
 TEST_F (AXPositionTest, AsLeafTextPositionBeforeCharacterNoAdjustment)
 
 TEST_F (AXPositionTest, AsLeafTextPositionAfterCharacterNoAdjustment)
 
 TEST_F (AXPositionTest, AsLeafTextPositionBeforeCharacter)
 
 TEST_F (AXPositionTest, AsLeafTextPositionAfterCharacter)
 
 TEST_F (AXPositionTest, CreateNextAndPreviousCharacterPositionWithNullPosition)
 
 TEST_F (AXPositionTest, AsValidPosition)
 
 TEST_F (AXPositionTest, AsValidPositionInDescendantOfEmptyObject)
 
 TEST_F (AXPositionTest, CreateNextCharacterPosition)
 
 TEST_F (AXPositionTest, CreatePreviousCharacterPosition)
 
 TEST_F (AXPositionTest, CreateNextCharacterPositionAtGraphemeBoundary)
 
 TEST_F (AXPositionTest, CreatePreviousCharacterPositionAtGraphemeBoundary)
 
 TEST_F (AXPositionTest, ReciprocalCreateNextAndPreviousCharacterPosition)
 
 TEST_F (AXPositionTest, CreateNextAndPreviousWordStartPositionWithNullPosition)
 
 TEST_F (AXPositionTest, CreateNextAndPreviousWordEndPositionWithNullPosition)
 
 TEST_F (AXPositionTest, OperatorEquals)
 
 TEST_F (AXPositionTest, OperatorEqualsSameTextOffsetSameAnchorId)
 
 TEST_F (AXPositionTest, OperatorEqualsSameTextOffsetDifferentAnchorIdRoot)
 
 TEST_F (AXPositionTest, OperatorEqualsSameTextOffsetDifferentAnchorIdLeaf)
 
 TEST_F (AXPositionTest, OperatorsLessThanAndGreaterThan)
 
 TEST_F (AXPositionTest, Swap)
 
 TEST_F (AXPositionTest, CreateNextAnchorPosition)
 
 TEST_F (AXPositionTest, CreateLinePositionsMultipleAnchorsInSingleLine)
 
 TEST_F (AXPositionTest, CreateNextWordPositionInList)
 
 TEST_F (AXPositionTest, CreatePreviousWordPositionInList)
 
 TEST_F (AXPositionTest, EmptyObjectReplacedByCharacterTextNavigation)
 
 TEST_F (AXPositionTest, TextNavigationWithCollapsedCombobox)
 
 TEST_P (AXPositionExpandToEnclosingTextBoundaryTestWithParam, TextPositionBeforeLine2)
 
 TEST_P (AXPositionCreatePositionAtTextBoundaryTestWithParam, TextPositionBeforeStaticText)
 
 TEST_P (AXPositionTextNavigationTestWithParam, TraverseTreeStartingWithAffinityDownstream)
 
 TEST_P (AXPositionTextNavigationTestWithParam, TraverseTreeStartingWithAffinityUpstream)
 
 INSTANTIATE_TEST_SUITE_P (ExpandToEnclosingTextBoundary, AXPositionExpandToEnclosingTextBoundaryTestWithParam, testing::Values(ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kCharacter, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=6 affinity=downstream " "annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=7 affinity=downstream " "annotated_text=Line 1\n<L>ine 2"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kCharacter, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=7 affinity=downstream " "annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=8 affinity=downstream " "annotated_text=Line 1\nL<i>ne 2"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kFormat, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=13 affinity=downstream " "annotated_text=Line 1\nLine 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kFormat, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=13 affinity=downstream " "annotated_text=Line 1\nLine 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineEnd, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=6 affinity=downstream " "annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=13 affinity=downstream " "annotated_text=Line 1\nLine 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineEnd, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=6 affinity=downstream " "annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=13 affinity=downstream " "annotated_text=Line 1\nLine 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineStart, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=7 affinity=downstream " "annotated_text=Line 1\n<L>ine 2"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineStart, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=7 affinity=downstream " "annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 affinity=downstream " "annotated_text=Line 1\nLine 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineStartOrEnd, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=6 affinity=downstream " "annotated_text=Line 1<\n>Line 2"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineStartOrEnd, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=7 affinity=downstream " "annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 affinity=downstream " "annotated_text=Line 1\nLine 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kObject, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=13 affinity=downstream " "annotated_text=Line 1\nLine 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kObject, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=13 affinity=downstream " "annotated_text=Line 1\nLine 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphEnd, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=7 affinity=upstream " "annotated_text=Line 1\n<L>ine 2"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphEnd, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=7 affinity=upstream " "annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 affinity=downstream " "annotated_text=Line 1\nLine 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphStart, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=7 affinity=downstream " "annotated_text=Line 1\n<L>ine 2"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphStart, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=7 affinity=downstream " "annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 affinity=downstream " "annotated_text=Line 1\nLine 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphStartOrEnd, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=7 affinity=upstream " "annotated_text=Line 1\n<L>ine 2"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphStartOrEnd, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=7 affinity=downstream " "annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 affinity=downstream " "annotated_text=Line 1\nLine 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kWebPage, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=1 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=9 text_offset=6 affinity=downstream " "annotated_text=Line 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kWebPage, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=1 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=9 text_offset=6 affinity=downstream " "annotated_text=Line 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordEnd, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=6 affinity=downstream " "annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=11 affinity=downstream " "annotated_text=Line 1\nLine< >2"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordEnd, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=6 affinity=downstream " "annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=11 affinity=downstream " "annotated_text=Line 1\nLine< >2"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordStart, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=5 affinity=downstream " "annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=4 text_offset=7 affinity=downstream " "annotated_text=Line 1\n<L>ine 2"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordStart, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=7 affinity=downstream " "annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=12 affinity=downstream " "annotated_text=Line 1\nLine <2>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordStartOrEnd, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=5 affinity=downstream " "annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=4 text_offset=6 affinity=downstream " "annotated_text=Line 1<\n>Line 2"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordStartOrEnd, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=7 affinity=downstream " "annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=11 affinity=downstream " "annotated_text=Line 1\nLine< >2"}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePositionAtTextBoundary, AXPositionCreatePositionAtTextBoundaryTestWithParam, testing::Values(CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kCharacter, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=7 text_offset=0 affinity=downstream " "annotated_text=<\n>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kCharacter, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=8 text_offset=1 affinity=downstream " "annotated_text=L<i>ne 2"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kFormat, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=7 text_offset=0 affinity=downstream " "annotated_text=<\n>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kFormat, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=8 text_offset=6 affinity=downstream " "annotated_text=Line 2<>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineEnd, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=7 text_offset=0 affinity=downstream " "annotated_text=<\n>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineEnd, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=8 text_offset=6 affinity=downstream " "annotated_text=Line 2<>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineStart, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=6 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineStart, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "NullPosition"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineStartOrEnd, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=6 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineStartOrEnd, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=8 text_offset=6 affinity=downstream " "annotated_text=Line 2<>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kObject, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=8 text_offset=0 affinity=downstream " "annotated_text=<L>ine 2"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kObject, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=8 text_offset=6 affinity=downstream " "annotated_text=Line 2<>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphEnd, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=3 text_offset=0 affinity=downstream " "annotated_text=<>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphEnd, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=8 text_offset=6 affinity=downstream " "annotated_text=Line 2<>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphStart, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=6 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphStart, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "NullPosition"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphStartOrEnd, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=6 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphStartOrEnd, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=8 text_offset=6 affinity=downstream " "annotated_text=Line 2<>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kWebPage, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=1 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kWebPage, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=9 text_offset=6 affinity=downstream " "annotated_text=Line 2<>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordEnd, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=6 text_offset=6 affinity=downstream " "annotated_text=Line 1<>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordEnd, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=8 text_offset=4 affinity=downstream " "annotated_text=Line< >2"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordStart, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=6 text_offset=5 affinity=downstream " "annotated_text=Line <1>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordStart, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=8 text_offset=5 affinity=downstream " "annotated_text=Line <2>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordStartOrEnd, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=6 text_offset=5 affinity=downstream " "annotated_text=Line <1>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordStartOrEnd, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=8 text_offset=4 affinity=downstream " "annotated_text=Line< >2"}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextWordStartPositionWithBoundaryBehaviorCrossBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::CrossBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=5 " "affinity=downstream annotated_text=Line <1>", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=5 " "affinity=downstream annotated_text=Line <2>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=5 " "affinity=downstream annotated_text=Line <2>", "NullPosition"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextWordStartPositionWithBoundaryBehaviorStopAtAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=5 " "affinity=downstream annotated_text=Line <1>", "TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=5 " "affinity=downstream annotated_text=Line <2>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextWordStartPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=5 " "affinity=downstream annotated_text=Line <1>", "TextPosition anchor_id=5 text_offset=5 " "affinity=downstream annotated_text=Line <1>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=5 " "affinity=downstream annotated_text=Line <2>", "TextPosition anchor_id=9 text_offset=5 " "affinity=downstream annotated_text=Line <2>"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextWordStartPositionWithBoundaryBehaviorStopAtLastAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=5 " "affinity=downstream annotated_text=Line <1>", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=5 " "affinity=downstream annotated_text=Line <2>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=5 " "affinity=downstream annotated_text=Line <2>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousWordStartPositionWithBoundaryBehaviorCrossBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::CrossBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=6 text_offset=5 " "affinity=downstream annotated_text=Line <1>", "TextPosition anchor_id=6 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "NullPosition"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousWordStartPositionWithBoundaryBehaviorStopAtAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousWordStartPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=1 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=4 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=5 " "affinity=downstream annotated_text=Line <1>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousWordStartPositionWithBoundaryBehaviorStopAtLastAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=6 text_offset=5 " "affinity=downstream annotated_text=Line <1>", "TextPosition anchor_id=6 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "TextPosition anchor_id=6 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextWordEndPositionWithBoundaryBehaviorCrossBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::CrossBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=4 " "affinity=downstream annotated_text=Line< >1", "TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=9 text_offset=4 " "affinity=downstream annotated_text=Line< >2", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "NullPosition"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextWordEndPositionWithBoundaryBehaviorStopAtAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=4 " "affinity=downstream annotated_text=Line< >1", "TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextWordEndPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=1 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=4 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=4 " "affinity=downstream annotated_text=Line< >1", "TextPosition anchor_id=5 text_offset=4 " "affinity=downstream annotated_text=Line< >1"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=4 " "affinity=downstream annotated_text=Line< >2"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextWordEndPositionWithBoundaryBehaviorStopAtLastAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=4 " "affinity=downstream annotated_text=Line< >1", "TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=9 text_offset=4 " "affinity=downstream annotated_text=Line< >2", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousWordEndPositionWithBoundaryBehaviorCrossBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::CrossBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=4 " "affinity=downstream annotated_text=Line< >1", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=6 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=6 text_offset=4 " "affinity=downstream annotated_text=Line< >1", "NullPosition"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousWordEndPositionWithBoundaryBehaviorStopAtAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 13, { "TextPosition anchor_id=1 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", }}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=4 " "affinity=downstream annotated_text=Line< >1", "TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousWordEndPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=4 " "affinity=downstream annotated_text=Line< >1", "TextPosition anchor_id=5 text_offset=4 " "affinity=downstream annotated_text=Line< >1"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=4 " "affinity=downstream annotated_text=Line< >2"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousWordEndPositionWithBoundaryBehaviorStopAtLastAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=4 " "affinity=downstream annotated_text=Line< >1", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=6 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=6 text_offset=4 " "affinity=downstream annotated_text=Line< >1", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextLineStartPositionWithBoundaryBehaviorCrossBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::CrossBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"NullPosition"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextLineStartPositionWithBoundaryBehaviorStopAtAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextLineStartPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"NullPosition"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextLineStartPositionWithBoundaryBehaviorStopAtLastAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousLineStartPositionWithBoundaryBehaviorCrossBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::CrossBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=6 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "NullPosition"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousLineStartPositionWithBoundaryBehaviorStopAtAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousLineStartPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousLineStartPositionWithBoundaryBehaviorStopAtLastAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=6 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "TextPosition anchor_id=6 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextLineEndPositionWithBoundaryBehaviorCrossBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::CrossBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "NullPosition"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextLineEndPositionWithBoundaryBehaviorStopAtAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextLineEndPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextLineEndPositionWithBoundaryBehaviorStopAtLastAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousLineEndPositionWithBoundaryBehaviorCrossBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 5, {"NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 5, {"NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=6 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 0, {"TextPosition anchor_id=7 text_offset=0 " "affinity=downstream annotated_text=<\n>", "NullPosition"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousLineEndPositionWithBoundaryBehaviorStopAtAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 5, {"TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 5, {"TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 0, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousLineEndPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 12, {"TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 12, {"TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX1_ID, 2, {"NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=6 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=6 text_offset=6 " "affinity=downstream annotated_text=Line 1<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 0, {"TextPosition anchor_id=6 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=6 text_offset=6 " "affinity=downstream annotated_text=Line 1<>"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousLineEndPositionWithBoundaryBehaviorStopAtLastAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 5, {"TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 5, {"TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=6 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 0, {"TextPosition anchor_id=7 text_offset=0 " "affinity=downstream annotated_text=<\n>", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextParagraphStartPositionWithBoundaryBehaviorCrossBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::CrossBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"NullPosition"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextParagraphStartPositionWithBoundaryBehaviorStopAtAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextParagraphStartPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"NullPosition"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextParagraphStartPositionWithBoundaryBehaviorStopAtLastAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousParagraphStartPositionWithBoundaryBehaviorCrossBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::CrossBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=6 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "NullPosition"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousParagraphStartPositionWithBoundaryBehaviorStopAtAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousParagraphStartPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousParagraphStartPositionWithBoundaryBehaviorStopAtLastAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=6 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "TextPosition anchor_id=6 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextParagraphEndPositionWithBoundaryBehaviorCrossBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::CrossBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "NullPosition"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextParagraphEndPositionWithBoundaryBehaviorStopAtAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextParagraphEndPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>", "TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, LINE_BREAK_ID, 0, {"TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>", "TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, LINE_BREAK_ID, 1, {"TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>", "TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreateNextParagraphEndPositionWithBoundaryBehaviorStopAtLastAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousParagraphEndPositionWithBoundaryBehaviorCrossBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 5, {"TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 5, {"TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>", "TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 0, {"TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>", "NullPosition"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousParagraphEndPositionWithBoundaryBehaviorStopAtAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 5, {"TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 5, {"TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 0, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousParagraphEndPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 12, {"TextPosition anchor_id=1 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 12, {"TextPosition anchor_id=4 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX1_ID, 2, {"TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>", "TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 0, {"TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>", "TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, LINE_BREAK_ID, 0, {"TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, LINE_BREAK_ID, 1, {"TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>", "TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>"}}))
 
 INSTANTIATE_TEST_SUITE_P (CreatePreviousParagraphEndPositionWithBoundaryBehaviorStopAtLastAnchorBoundary, AXPositionTextNavigationTestWithParam, testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 5, {"TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 5, {"TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>", "TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 0, {"TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>"}}))
 
template<class AXPositionType , class AXNodeType >
bool operator== (const AXPosition< AXPositionType, AXNodeType > &first, const AXPosition< AXPositionType, AXNodeType > &second)
 
template<class AXPositionType , class AXNodeType >
bool operator!= (const AXPosition< AXPositionType, AXNodeType > &first, const AXPosition< AXPositionType, AXNodeType > &second)
 
template<class AXPositionType , class AXNodeType >
bool operator< (const AXPosition< AXPositionType, AXNodeType > &first, const AXPosition< AXPositionType, AXNodeType > &second)
 
template<class AXPositionType , class AXNodeType >
bool operator<= (const AXPosition< AXPositionType, AXNodeType > &first, const AXPosition< AXPositionType, AXNodeType > &second)
 
template<class AXPositionType , class AXNodeType >
bool operator> (const AXPosition< AXPositionType, AXNodeType > &first, const AXPosition< AXPositionType, AXNodeType > &second)
 
template<class AXPositionType , class AXNodeType >
bool operator>= (const AXPosition< AXPositionType, AXNodeType > &first, const AXPosition< AXPositionType, AXNodeType > &second)
 
template<class AXPositionType , class AXNodeType >
void swap (AXPosition< AXPositionType, AXNodeType > &first, AXPosition< AXPositionType, AXNodeType > &second)
 
template<class AXPositionType , class AXNodeType >
std::ostream & operator<< (std::ostream &stream, const AXPosition< AXPositionType, AXNodeType > &position)
 
template<class AXPositionType >
std::ostream & operator<< (std::ostream &stream, const AXRange< AXPositionType > &range)
 
 TEST_F (AXRangeTest, EqualityOperators)
 
 TEST_F (AXRangeTest, AsForwardRange)
 
 TEST_F (AXRangeTest, IsCollapsed)
 
 TEST_F (AXRangeTest, BeginAndEndIterators)
 
 TEST_F (AXRangeTest, LeafTextRangeIteration)
 
 TEST_F (AXRangeTest, GetTextWithWholeObjects)
 
 TEST_F (AXRangeTest, GetTextWithTextOffsets)
 
 TEST_F (AXRangeTest, GetTextWithEmptyRanges)
 
 TEST_F (AXRangeTest, GetTextAddingNewlineBetweenParagraphs)
 
 TEST_F (AXRangeTest, GetTextWithMaxCount)
 
 TEST_F (AXRangeTest, GetTextWithList)
 
 TEST_F (AXRangeTest, GetRects)
 
 TEST_F (AXRangeTest, GetRectsOffscreen)
 
std::ostream & operator<< (std::ostream &stream, const AXRelativeBounds &bounds)
 
bool HasPresentationalChildren (const ax::mojom::Role role)
 
bool IsAlert (const ax::mojom::Role role)
 
bool IsButton (const ax::mojom::Role role)
 
bool IsClickable (const ax::mojom::Role role)
 
bool IsCellOrTableHeader (const ax::mojom::Role role)
 
bool IsContainerWithSelectableChildren (const ax::mojom::Role role)
 
bool IsControl (const ax::mojom::Role role)
 
bool IsControlOnAndroid (const ax::mojom::Role role, bool isFocusable)
 
bool IsDocument (const ax::mojom::Role role)
 
bool IsDialog (const ax::mojom::Role role)
 
bool IsForm (const ax::mojom::Role role)
 
bool IsFormatBoundary (const ax::mojom::Role role)
 
bool IsHeading (const ax::mojom::Role role)
 
bool IsHeadingOrTableHeader (const ax::mojom::Role role)
 
bool IsIframe (ax::mojom::Role role)
 
bool IsImageOrVideo (const ax::mojom::Role role)
 
bool IsImage (const ax::mojom::Role role)
 
bool IsItemLike (const ax::mojom::Role role)
 
bool IsLandmark (const ax::mojom::Role role)
 
bool IsLink (const ax::mojom::Role role)
 
bool IsList (const ax::mojom::Role role)
 
bool IsListItem (const ax::mojom::Role role)
 
bool IsMenuItem (ax::mojom::Role role)
 
bool IsMenuRelated (const ax::mojom::Role role)
 
bool IsPresentational (const ax::mojom::Role role)
 
bool IsRadio (const ax::mojom::Role role)
 
bool IsRangeValueSupported (const ax::mojom::Role role)
 
bool IsReadOnlySupported (const ax::mojom::Role role)
 
bool IsRowContainer (const ax::mojom::Role role)
 
bool IsSection (const ax::mojom::Role role)
 
bool IsSectionhead (const ax::mojom::Role role)
 
bool IsSelect (const ax::mojom::Role role)
 
bool IsSetLike (const ax::mojom::Role role)
 
bool IsStaticList (const ax::mojom::Role role)
 
bool IsStructure (const ax::mojom::Role role)
 
bool IsTableColumn (ax::mojom::Role role)
 
bool IsTableHeader (ax::mojom::Role role)
 
bool IsTableLike (const ax::mojom::Role role)
 
bool IsTableRow (ax::mojom::Role role)
 
bool IsText (ax::mojom::Role role)
 
bool SupportsExpandCollapse (const ax::mojom::Role role)
 
bool SupportsHierarchicalLevel (const ax::mojom::Role role)
 
bool SupportsOrientation (const ax::mojom::Role role)
 
bool SupportsSelected (const ax::mojom::Role role)
 
bool SupportsToggle (const ax::mojom::Role role)
 
bool ShouldHaveReadonlyStateByDefault (const ax::mojom::Role role)
 
 TEST (AXRolePropertiesTest, TestSupportsHierarchicalLevel)
 
 TEST (AXRolePropertiesTest, TestSupportsToggle)
 
 TEST_F (AXTableInfoTest, SimpleTable)
 
 TEST_F (AXTableInfoTest, ComputedTableSizeIncludesSpans)
 
 TEST_F (AXTableInfoTest, AuthorRowAndColumnCountsAreRespected)
 
 TEST_F (AXTableInfoTest, TableInfoRecomputedOnlyWhenTableChanges)
 
 TEST_F (AXTableInfoTest, CellIdsHandlesSpansAndMissingCells)
 
 TEST_F (AXTableInfoTest, SkipsGenericAndIgnoredNodes)
 
 TEST_F (AXTableInfoTest, HeadersWithSpans)
 
 TEST_F (AXTableInfoTest, ExtraMacNodes)
 
 TEST_F (AXTableInfoTest, TableWithNoIndices)
 
 TEST_F (AXTableInfoTest, TableWithPartialIndices)
 
 TEST_F (AXTableInfoTest, BadRowIndicesIgnored)
 
 TEST_F (AXTableInfoTest, BadColIndicesIgnored)
 
 TEST_F (AXTableInfoTest, AriaIndicesInferred)
 
 TEST_F (AXTableInfoTest, TableChanges)
 
 TEST_F (AXTableInfoTest, ExtraMacNodesChanges)
 
 TEST_F (AXTableInfoTest, RowColumnSpanChanges)
 
bool operator== (const AXTreeData &lhs, const AXTreeData &rhs)
 
bool operator!= (const AXTreeData &lhs, const AXTreeData &rhs)
 
void swap (AXTreeID &first, AXTreeID &second)
 
std::ostream & operator<< (std::ostream &stream, const AXTreeID &value)
 
const AXTreeIDAXTreeIDUnknown ()
 
 TEST (AXTreeTest, SerializeAXTreeUpdate)
 
 TEST (AXTreeTest, LeaveOrphanedDeletedSubtreeFails)
 
 TEST (AXTreeTest, LeaveOrphanedNewChildFails)
 
 TEST (AXTreeTest, DuplicateChildIdFails)
 
 TEST (AXTreeTest, InvalidReparentingFails)
 
 TEST (AXTreeTest, NoReparentingOfRootIfNoNewRoot)
 
 TEST (AXTreeTest, NoReparentingIfOnlyRemovedAndChangedNotReAdded)
 
 TEST (AXTreeTest, NoReparentingIfRemovedMultipleTimesAndNotInFinalTree)
 
 TEST (AXTreeTest, ReparentIfRemovedMultipleTimesButExistsInFinalTree)
 
 TEST (AXTreeTest, ReparentRootIfRootChanged)
 
 TEST (AXTreeTest, ImplicitChildrenDelete)
 
 TEST (AXTreeTest, IndexInParentAfterReorder)
 
 TEST (AXTreeTest, IndexInParentAfterReorderIgnoredNode)
 
 TEST (AXTreeTest, ImplicitAttributeDelete)
 
 TEST (AXTreeTest, TreeObserverIsCalled)
 
 TEST (AXTreeTest, TreeObserverIsCalledForTreeDataChanges)
 
 TEST (AXTreeTest, ReparentingDoesNotTriggerNodeCreated)
 
 TEST (AXTreeTest, MultipleIgnoredChangesDoesNotBreakCache)
 
 TEST (AXTreeTest, NodeToClearUpdatesParentUnignoredCount)
 
 TEST (AXTreeTest, TreeObserverIsNotCalledForReparenting)
 
 TEST (AXTreeTest, BogusAXTree)
 
 TEST (AXTreeTest, BogusAXTree2)
 
 TEST (AXTreeTest, BogusAXTree3)
 
 TEST (AXTreeTest, RoleAndStateChangeCallbacks)
 
 TEST (AXTreeTest, AttributeChangeCallbacks)
 
 TEST (AXTreeTest, IntListChangeCallbacks)
 
 TEST (AXTreeTest, GetBoundsBasic)
 
 TEST (AXTreeTest, EmptyNodeBoundsIsUnionOfChildren)
 
 TEST (AXTreeTest, EmptyNodeNotOffscreenEvenIfAllChildrenOffscreen)
 
 TEST (AXTreeTest, GetBoundsWithTransform)
 
 TEST (AXTreeTest, GetBoundsWithContainerId)
 
 TEST (AXTreeTest, GetBoundsWithScrolling)
 
 TEST (AXTreeTest, GetBoundsOfNodeWithZeroSize)
 
 TEST (AXTreeTest, GetBoundsEmptyBoundsInheritsFromParent)
 
 TEST (AXTreeTest, GetBoundsCropsChildToRoot)
 
 TEST (AXTreeTest, GetBoundsSetsOffscreenIfClipsChildren)
 
 TEST (AXTreeTest, GetBoundsUpdatesOffscreen)
 
 TEST (AXTreeTest, IntReverseRelations)
 
 TEST (AXTreeTest, IntListReverseRelations)
 
 TEST (AXTreeTest, DeletingNodeUpdatesReverseRelations)
 
 TEST (AXTreeTest, ReverseRelationsDoNotKeepGrowing)
 
 TEST (AXTreeTest, SkipIgnoredNodes)
 
 TEST (AXTreeTest, CachedUnignoredValues)
 
 TEST (AXTreeTest, TestRecursionUnignoredChildCount)
 
 TEST (AXTreeTest, NullUnignoredChildren)
 
 TEST (AXTreeTest, UnignoredChildIteratorIncrementDecrementPastEnd)
 
 TEST (AXTreeTest, UnignoredChildIteratorIgnoredContainerSiblings)
 
 TEST (AXTreeTest, UnignoredChildIterator)
 
 TEST (AXTreeTest, UnignoredAccessors)
 
 TEST (AXTreeTest, UnignoredNextPreviousChild)
 
 TEST (AXTreeTest, GetSiblingsNoIgnored)
 
 TEST (AXTreeTest, GetUnignoredSiblingsChildrenPromoted)
 
 TEST (AXTreeTest, GetUnignoredSiblingsIgnoredChildSkipped)
 
 TEST (AXTreeTest, GetUnignoredSiblingIgnoredParentIrrelevant)
 
 TEST (AXTreeTest, GetUnignoredSiblingsAllIgnored)
 
 TEST (AXTreeTest, GetUnignoredSiblingsNestedIgnored)
 
 TEST (AXTreeTest, UnignoredSelection)
 
 TEST (AXTreeTest, GetChildrenOrSiblings)
 
 TEST (AXTreeTest, SetSizePosInSetAssigned)
 
 TEST (AXTreeTest, SetSizePosInSetUnassigned)
 
 TEST (AXTreeTest, SetSizeAssignedOnContainer)
 
 TEST (AXTreeTest, SetSizePosInSetDiverseList)
 
 TEST (AXTreeTest, SetSizePosInSetNestedList)
 
 TEST (AXTreeTest, PosInSetMissing)
 
 TEST (AXTreeTest, SetSizePosInSetMissingDifficult)
 
 TEST (AXTreeTest, SetSizeDecreasing)
 
 TEST (AXTreeTest, PosInSetDecreasing)
 
 TEST (AXTreeTest, PosInSetDuplicates)
 
 TEST (AXTreeTest, SetSizePosInSetNestedContainer)
 
 TEST (AXTreeTest, SetSizePosInSetDeleteItem)
 
 TEST (AXTreeTest, SetSizePosInSetAddItem)
 
 TEST (AXTreeTest, OrderedSetReportsSetSize)
 
 TEST (AXTreeTest, SetSizePosInSetInvalid)
 
 TEST (AXTreeTest, SetSizePosInSetRadioButtons)
 
 TEST (AXTreeTest, SetSizePosInSetRadioButtonsInList)
 
 TEST (AXTreeTest, SetSizePosInSetFlatTree)
 
 TEST (AXTreeTest, SetSizePosInSetFlatTreeLevelsOnly)
 
 TEST (AXTreeTest, SetSizePosInSetSubtreeDeleted)
 
 TEST (AXTreeTest, SetSizePosInSetIgnoredItem)
 
 TEST (AXTreeTest, SetSizePosInSetPopUpButton)
 
 TEST (AXTreeTest, SetSizePosInSetUnkown)
 
 TEST (AXTreeTest, SetSizePosInSetMenuItemValidChildOfMenuListPopup)
 
 TEST (AXTreeTest, SetSizePostInSetListBoxOptionWithGroup)
 
 TEST (AXTreeTest, SetSizePosInSetGroup)
 
 TEST (AXTreeTest, SetSizePosInSetHidden)
 
 TEST (AXTreeTest, SetSizePosInSetControls)
 
 TEST (AXTreeTest, SetSizePosInSetLeafPopUpButton)
 
 TEST (AXTreeTest, OnNodeWillBeDeletedHasValidUnignoredParent)
 
 TEST (AXTreeTest, OnNodeHasBeenDeleted)
 
 TEST (AXTreeTest, SingleUpdateDeletesNewlyCreatedChildNode)
 
 TEST (AXTreeTest, SingleUpdateReparentsNodeMultipleTimes)
 
 TEST (AXTreeTest, SingleUpdateIgnoresNewlyCreatedUnignoredChildNode)
 
 TEST (AXTreeTest, SingleUpdateTogglesIgnoredStateAfterCreatingNode)
 
 TEST (AXTreeTest, SingleUpdateTogglesIgnoredStateBeforeDestroyingNode)
 
 TEST (AXTreeTest, TestIsInListMarker)
 
template<typename AXNodeData , typename AXTreeData >
bool TreeUpdatesCanBeMerged (const AXTreeUpdateBase< AXNodeData, AXTreeData > &u1, const AXTreeUpdateBase< AXNodeData, AXTreeData > &u2)
 
 TEST_F (AXFragmentRootTest, UIAFindItemByPropertyUniqueId)
 
 TEST_F (AXFragmentRootTest, TestUIAGetFragmentRoot)
 
 TEST_F (AXFragmentRootTest, DISABLED_TestUIAElementProviderFromPoint)
 
 TEST_F (AXFragmentRootTest, TestUIAGetFocus)
 
 TEST_F (AXFragmentRootTest, TestUIAErrorHandling)
 
 TEST_F (AXFragmentRootTest, TestGetChildCount)
 
 TEST_F (AXFragmentRootTest, TestChildAtIndex)
 
 TEST_F (AXFragmentRootTest, TestGetParent)
 
 TEST_F (AXFragmentRootTest, TestGetPropertyValue)
 
 TEST_F (AXFragmentRootTest, TestUIAMultipleFragmentRoots)
 
 TEST_F (AXFragmentRootTest, TestFragmentRootMap)
 
std::ostream & operator<< (std::ostream &stream, AXPlatformNode &node)
 
 TEST (AXPlatformNodeBaseTest, GetHypertext)
 
 TEST (AXPlatformNodeBaseTest, GetHypertextIgnoredContainerSiblings)
 
 TEST (AXPlatformNodeBaseTest, InnerTextIgnoresInvisibleAndIgnored)
 
 TEST (AXPlatformNodeBaseTest, TestSelectedChildren)
 
 TEST (AXPlatformNodeBaseTest, TestSelectedChildrenWithGroup)
 
 TEST (AXPlatformNodeBaseTest, TestSelectedChildrenMixed)
 
 TEST (AXPlatformNodeBaseTest, CompareTo)
 
bool IsValuePatternSupported (AXPlatformNodeDelegate *delegate)
 
AX_EXPORT bool IsNameExposedInAXValueForRole (ax::mojom::Role role)
 
 TEST_F (AXPlatformNodeMacTest, CanGetCocoaPlatformNodeFromTree)
 
 TEST_F (AXPlatformNodeMacTest, AccessibilityRangeForPositionDoesntCrash)
 
 TEST_F (AXPlatformNodeTextProviderTest, CreateDegenerateRangeFromStart)
 
 TEST_F (AXPlatformNodeTextProviderTest, ITextProviderRangeFromChild)
 
 TEST_F (AXPlatformNodeTextProviderTest, ITextProviderRangeFromChildMultipleChildren)
 
 TEST_F (AXPlatformNodeTextProviderTest, NearestTextIndexToPoint)
 
 TEST_F (AXPlatformNodeTextProviderTest, ITextProviderDocumentRange)
 
 TEST_F (AXPlatformNodeTextProviderTest, DISABLED_ITextProviderDocumentRangeTrailingIgnored)
 
 TEST_F (AXPlatformNodeTextProviderTest, ITextProviderDocumentRangeNested)
 
 TEST_F (AXPlatformNodeTextProviderTest, ITextProviderSupportedSelection)
 
 TEST_F (AXPlatformNodeTextProviderTest, ITextProviderGetSelection)
 
 TEST_F (AXPlatformNodeTextProviderTest, ITextProviderGetActiveComposition)
 
 TEST_F (AXPlatformNodeTextProviderTest, ITextProviderGetConversionTarget)
 
static bool StringSearchBasic (const std::u16string_view search_string, const std::u16string_view find_in, size_t *find_start, size_t *find_length, bool backwards)
 
bool StringSearch (std::u16string_view search_string, std::u16string_view find_in, size_t *find_start, size_t *find_length, bool ignore_case, bool backwards)
 
static bool StringCompareICU (BSTR left, BSTR right)
 
static AXNodePosition::AXPositionInstance CreateTextPosition (const AXNode &anchor, int text_offset, ax::mojom::TextAffinity affinity)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestITextRangeProviderClone)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestITextRangeProviderCompareEndpoints)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestITextRangeProviderExpandToEnclosingCharacter)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestITextRangeProviderExpandToEnclosingWord)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestITextRangeProviderExpandToEnclosingLine)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestITextRangeProviderExpandToEnclosingParagraph)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestITextRangeProviderExpandToEnclosingFormat)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestITextRangeProviderExpandToEnclosingFormatWithEmptyObjects)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestITextRangeProviderExpandToEnclosingDocument)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestITextRangeProviderIgnoredForTextNavigation)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestITextRangeProviderInvalidCalls)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestITextRangeProviderGetText)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestITextRangeProviderMoveCharacter)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestITextRangeProviderMoveFormat)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestITextRangeProviderMoveWord)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestITextRangeProviderMoveLine)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestITextRangeProviderMoveParagraph)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestITextRangeProviderMoveDocument)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestITextRangeProviderMove)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestITextRangeProviderMoveEndpointByDocument)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestITextRangeProviderMoveEndpointByCharacterMultilingual)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestITextRangeProviderMoveEndpointByWord)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestITextRangeProviderMoveEndpointByLine)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestITextRangeProviderMoveEndpointByUnitTextField)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestITextRangeProviderMoveEndpointByFormat)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestITextRangeProviderCompare)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestITextRangeProviderSelection)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestITextRangeProviderGetBoundingRectangles)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestITextRangeProviderGetEnclosingElement)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestITextRangeProviderGetEnclosingElementRichButton)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestITextRangeProviderMoveEndpointByRange)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestITextRangeProviderGetAttributeValue)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestITextRangeProviderGetAttributeValueAnnotationObjects)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestITextRangeProviderGetAttributeValueAnnotationObjectsMixed)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestITextRangeProviderGetAttributeValueNotSupported)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestITextRangeProviderGetAttributeValueWithAncestorTextPosition)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestITextRangeProviderSelect)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestITextRangeProviderSelectListMarker)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestITextRangeProviderFindText)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, FindTextWithEmbeddedObjectCharacter)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestITextRangeProviderFindTextBackwards)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestITextRangeProviderFindAttribute)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, ElementNotAvailable)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestITextRangeProviderIgnoredNodes)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestNormalizeTextRangePastEndOfDocument)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestNormalizeTextRangePastEndOfDocumentWithIgnoredNodes)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestNormalizeTextRangeInsideIgnoredNodes)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestNormalizeTextRangeSpanIgnoredNodes)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestNormalizeTextRangeForceSameAnchorOnDegenerateRange)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestValidateStartAndEnd)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestReplaceStartAndEndEndpointNode)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestDeleteSubtreeThatIncludesEndpoints)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestDeleteSubtreeWithIgnoredAncestors)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_TestDeleteSubtreeThatIncludesEndpointsNormalizeMoves)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestDeleteTreePositionPreviousSibling)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, TestReplaceStartAndEndEndpointRepeatRemoval)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, CaretAtEndOfTextFieldReadOnly)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_GeneratedNewlineReturnsCommonAnchorReadonly)
 
 TEST_F (AXPlatformNodeTextRangeProviderTest, DISABLED_MoveEndpointToLastIgnoredForTextNavigationNode)
 
 TEST_F (AXPlatformNodeWinTest, IAccessibleDetachedObject)
 
 TEST_F (AXPlatformNodeWinTest, IAccessibleHitTest)
 
 TEST_F (AXPlatformNodeWinTest, IAccessibleHitTestDoesNotLoopForever)
 
 TEST_F (AXPlatformNodeWinTest, IAccessibleName)
 
 TEST_F (AXPlatformNodeWinTest, IAccessibleDescription)
 
 TEST_F (AXPlatformNodeWinTest, IAccessibleAccValue)
 
 TEST_F (AXPlatformNodeWinTest, IAccessibleShortcut)
 
 TEST_F (AXPlatformNodeWinTest, IAccessibleSelectionListBoxOptionNothingSelected)
 
 TEST_F (AXPlatformNodeWinTest, IAccessibleSelectionListBoxOptionOneSelected)
 
 TEST_F (AXPlatformNodeWinTest, IAccessibleSelectionListBoxOptionMultipleSelected)
 
 TEST_F (AXPlatformNodeWinTest, IAccessibleSelectionTableNothingSelected)
 
 TEST_F (AXPlatformNodeWinTest, IAccessibleSelectionTableRowOneSelected)
 
 TEST_F (AXPlatformNodeWinTest, IAccessibleSelectionTableRowMultipleSelected)
 
 TEST_F (AXPlatformNodeWinTest, IAccessibleSelectionTableCellOneSelected)
 
 TEST_F (AXPlatformNodeWinTest, IAccessibleSelectionTableCellMultipleSelected)
 
 TEST_F (AXPlatformNodeWinTest, IAccessibleRole)
 
 TEST_F (AXPlatformNodeWinTest, IAccessibleLocation)
 
 TEST_F (AXPlatformNodeWinTest, IAccessibleChildAndParent)
 
 TEST_F (AXPlatformNodeWinTest, AccNavigate)
 
 TEST_F (AXPlatformNodeWinTest, AnnotatedImageName)
 
 TEST_F (AXPlatformNodeWinTest, IGridProviderGetRowCount)
 
 TEST_F (AXPlatformNodeWinTest, IGridProviderGetColumnCount)
 
 TEST_F (AXPlatformNodeWinTest, IGridProviderGetItem)
 
 TEST_F (AXPlatformNodeWinTest, ITableProviderGetColumnHeaders)
 
 TEST_F (AXPlatformNodeWinTest, ITableProviderGetColumnHeadersMultipleHeaders)
 
 TEST_F (AXPlatformNodeWinTest, ITableProviderGetRowHeaders)
 
 TEST_F (AXPlatformNodeWinTest, ITableProviderGetRowOrColumnMajor)
 
 TEST_F (AXPlatformNodeWinTest, ITableItemProviderGetColumnHeaderItems)
 
 TEST_F (AXPlatformNodeWinTest, ITableItemProviderGetRowHeaderItems)
 
 TEST_F (AXPlatformNodeWinTest, UIAGetPropertySimple)
 
 TEST_F (AXPlatformNodeWinTest, UIAGetPropertyValueClickablePoint)
 
 TEST_F (AXPlatformNodeWinTest, UIAGetPropertyValueIsDialog)
 
 TEST_F (AXPlatformNodeWinTest, UIAGetPropertyValueIsControlElementIgnoredInvisible)
 
 TEST_F (AXPlatformNodeWinTest, UIAGetControllerForPropertyId)
 
 TEST_F (AXPlatformNodeWinTest, UIAGetDescribedByPropertyId)
 
 TEST_F (AXPlatformNodeWinTest, UIAItemStatusPropertyId)
 
 TEST_F (AXPlatformNodeWinTest, UIAGetFlowsToPropertyId)
 
 TEST_F (AXPlatformNodeWinTest, UIAGetPropertyValueFlowsFromNone)
 
 TEST_F (AXPlatformNodeWinTest, UIAGetPropertyValueFlowsFromSingle)
 
 TEST_F (AXPlatformNodeWinTest, UIAGetPropertyValueFlowsFromMultiple)
 
 TEST_F (AXPlatformNodeWinTest, UIAGetPropertyValueFrameworkId)
 
 TEST_F (AXPlatformNodeWinTest, GetPropertyValue_LabeledByTest)
 
 TEST_F (AXPlatformNodeWinTest, GetPropertyValue_HelpText)
 
 TEST_F (AXPlatformNodeWinTest, GetPropertyValue_LocalizedControlType)
 
 TEST_F (AXPlatformNodeWinTest, GetPropertyValue_IsControlElement)
 
 TEST_F (AXPlatformNodeWinTest, UIAGetProviderOptions)
 
 TEST_F (AXPlatformNodeWinTest, UIAGetHostRawElementProvider)
 
 TEST_F (AXPlatformNodeWinTest, UIAGetBoundingRectangle)
 
 TEST_F (AXPlatformNodeWinTest, UIAGetFragmentRoot)
 
 TEST_F (AXPlatformNodeWinTest, UIAGetEmbeddedFragmentRoots)
 
 TEST_F (AXPlatformNodeWinTest, UIAGetRuntimeId)
 
 TEST_F (AXPlatformNodeWinTest, UIAIWindowProviderGetIsModalUnset)
 
 TEST_F (AXPlatformNodeWinTest, UIAIWindowProviderGetIsModalFalse)
 
 TEST_F (AXPlatformNodeWinTest, UIAIWindowProviderGetIsModalTrue)
 
 TEST_F (AXPlatformNodeWinTest, UIAIWindowProviderInvalidArgument)
 
 TEST_F (AXPlatformNodeWinTest, UIAIWindowProviderNotSupported)
 
 TEST_F (AXPlatformNodeWinTest, UIANavigate)
 
 TEST_F (AXPlatformNodeWinTest, ISelectionProviderCanSelectMultipleDefault)
 
 TEST_F (AXPlatformNodeWinTest, ISelectionProviderCanSelectMultipleTrue)
 
 TEST_F (AXPlatformNodeWinTest, ISelectionProviderIsSelectionRequiredDefault)
 
 TEST_F (AXPlatformNodeWinTest, ISelectionProviderIsSelectionRequiredTrue)
 
 TEST_F (AXPlatformNodeWinTest, ISelectionProviderGetSelectionNoneSelected)
 
 TEST_F (AXPlatformNodeWinTest, ISelectionProviderGetSelectionSingleItemSelected)
 
 TEST_F (AXPlatformNodeWinTest, ISelectionProviderGetSelectionMultipleItemsSelected)
 
 TEST_F (AXPlatformNodeWinTest, ComputeUIAControlType)
 
 TEST_F (AXPlatformNodeWinTest, UIALandmarkType)
 
 TEST_F (AXPlatformNodeWinTest, UIALocalizedLandmarkType)
 
 TEST_F (AXPlatformNodeWinTest, IRawElementProviderSimple2ShowContextMenu)
 
 TEST_F (AXPlatformNodeWinTest, UIAErrorHandling)
 
 TEST_F (AXPlatformNodeWinTest, GetPatternProviderSupportedPatterns)
 
 TEST_F (AXPlatformNodeWinTest, GetPatternProviderExpandCollapsePattern)
 
 TEST_F (AXPlatformNodeWinTest, GetPatternProviderInvokePattern)
 
 TEST_F (AXPlatformNodeWinTest, IExpandCollapsePatternProviderAction)
 
 TEST_F (AXPlatformNodeWinTest, IInvokeProviderInvoke)
 
 TEST_F (AXPlatformNodeWinTest, ISelectionItemProviderNotSupported)
 
 TEST_F (AXPlatformNodeWinTest, ISelectionItemProviderDisabled)
 
 TEST_F (AXPlatformNodeWinTest, ISelectionItemProviderNotSelectable)
 
 TEST_F (AXPlatformNodeWinTest, ISelectionItemProviderSimple)
 
 TEST_F (AXPlatformNodeWinTest, ISelectionItemProviderRadioButton)
 
 TEST_F (AXPlatformNodeWinTest, ISelectionItemProviderMenuItemRadio)
 
 TEST_F (AXPlatformNodeWinTest, ISelectionItemProviderTable)
 
 TEST_F (AXPlatformNodeWinTest, ISelectionItemProviderGrid)
 
 TEST_F (AXPlatformNodeWinTest, ISelectionItemProviderGetSelectionContainer)
 
 TEST_F (AXPlatformNodeWinTest, ISelectionItemProviderSelectFollowFocus)
 
 TEST_F (AXPlatformNodeWinTest, IValueProvider_GetValue)
 
 TEST_F (AXPlatformNodeWinTest, IValueProvider_SetValue)
 
 TEST_F (AXPlatformNodeWinTest, IValueProvider_IsReadOnly)
 
 TEST_F (AXPlatformNodeWinTest, IScrollProviderSetScrollPercent)
 
 TEST_F (AXPlatformNodeWinTest, MojoEventToUIAPropertyTest)
 
base::string16 GetIA2RelationFromIntAttr (ax::mojom::IntAttribute attribute)
 
base::string16 GetIA2RelationFromIntListAttr (ax::mojom::IntListAttribute attribute)
 
base::string16 GetIA2ReverseRelationFromIntAttr (ax::mojom::IntAttribute attribute)
 
base::string16 GetIA2ReverseRelationFromIntListAttr (ax::mojom::IntListAttribute attribute)
 
 TEST (AXPlatformUniqueIdTest, IdsAreUnique)
 
 TEST (AXPlatformUniqueIdTest, UnassignedIdsAreReused)
 
 TEST (AXPlatformUniqueIdTest, DoesCreateCorrectId)
 
std::optional< int32_t > ComputeAttribute (const ui::AXPlatformNodeDelegate *delegate, ax::mojom::IntAttribute attribute)
 

Variables

static std::optional< int32_t > g_active_popup_ax_unique_id
 
AXEmbeddedObjectBehavior g_ax_embedded_object_behavior
 
UniqueIdMap g_unique_id_map
 
const uint32_t kScreenReaderAndHTMLAccessibilityModes
 
static const int32_t kMaxId = 100
 
static const GUID kUiaEventTestCompleteSentinelGuid
 
static const GUID kUiaPropertyUniqueIdGuid
 

Typedef Documentation

◆ AXTreeUpdate

Definition at line 86 of file ax_tree_update.h.

◆ TestPositionInstance

using ui::TestPositionInstance = typedef std::unique_ptr<AXPosition<AXNodePosition, AXNode> >

Definition at line 24 of file ax_range_unittest.cc.

◆ TestPositionRange

Definition at line 28 of file ax_node_position_unittest.cc.

◆ TestPositionType

using ui::TestPositionType = typedef std::unique_ptr<AXPosition<AXNodePosition, AXNode> >

Definition at line 27 of file ax_node_position_unittest.cc.

◆ TextAttribute

using ui::TextAttribute = typedef std::pair<std::string, std::string>

Definition at line 39 of file ax_platform_node_delegate.h.

◆ TextAttributeList

using ui::TextAttributeList = typedef std::vector<TextAttribute>

Definition at line 40 of file ax_platform_node_delegate.h.

◆ TextAttributeMap

using ui::TextAttributeMap = typedef std::map<int, TextAttributeList>

Definition at line 46 of file ax_platform_node_delegate.h.

◆ UniqueIdMap

using ui::UniqueIdMap = typedef std::unordered_map<int32_t, AXPlatformNode*>

Definition at line 62 of file ax_platform_node_base.cc.

Enumeration Type Documentation

◆ AXBoundaryBehavior

enum class ui::AXBoundaryBehavior
strong
Enumerator
CrossBoundary 
StopAtAnchorBoundary 
StopIfAlreadyAtBoundary 
StopAtLastAnchorBoundary 

Definition at line 43 of file ax_position.h.

◆ AXBoundaryType

enum class ui::AXBoundaryType
strong
Enumerator
kNone 
kUnitBoundary 
kDocumentStart 
kDocumentEnd 

Definition at line 53 of file ax_position.h.

53 {
54 // Not at a unit boundary.
55 kNone,
56 // At a unit boundary (e.g. a format boundary).
58 // At the start of a document.
60 // At the end of a document.
62};
@ kNone
Definition: layer.h:53

◆ AXClippingBehavior

enum class ui::AXClippingBehavior
strong
Enumerator
kUnclipped 
kClipped 

Definition at line 16 of file ax_clipping_behavior.h.

◆ AXCoordinateSystem

enum class ui::AXCoordinateSystem
strong
Enumerator
kScreenPhysicalPixels 
kScreenDIPs 
kRootFrame 
kFrame 

Definition at line 28 of file ax_coordinate_system.h.

◆ AXEmbeddedObjectBehavior

enum class ui::AXEmbeddedObjectBehavior
strong
Enumerator
kExposeCharacter 
kSuppressCharacter 

Definition at line 98 of file ax_position.h.

◆ AXOffscreenResult

enum class ui::AXOffscreenResult
strong
Enumerator
kOnscreen 
kOffscreen 

Definition at line 17 of file ax_offscreen_result.h.

◆ AXPositionAdjustmentBehavior

Enumerator
kMoveBackward 
kMoveForward 

Definition at line 67 of file ax_position.h.

◆ AXPositionKind

enum class ui::AXPositionKind
strong
Enumerator
NULL_POSITION 
TREE_POSITION 
TEXT_POSITION 

Definition at line 38 of file ax_position.h.

◆ AXRangeExpandBehavior

enum class ui::AXRangeExpandBehavior
strong
Enumerator
kLeftFirst 
kRightFirst 

Definition at line 79 of file ax_position.h.

79 {
80 // Expands to the left boundary first and then uses that position as the
81 // starting point to find the boundary to the right.
83 // Expands to the right boundary first and then uses that position as the
84 // starting point to find the boundary to the left.
86};

◆ AXTextConcatenationBehavior

Enumerator
kAsInnerText 
kAsTextContent 

Definition at line 25 of file ax_range.h.

25 {
26 // Preserve any introduced line breaks, e.g. GetText = "A\nB\nC".
28 // Ignore any introduced line breaks, e.g. GetText = "ABC".
30};

◆ AXTreePendingStructureStatus

Enumerator
kNotStarted 
kComputing 
kComplete 
kFailed 

Definition at line 236 of file ax_tree.cc.

236 {
237 // PendingStructureChanges have not begun computation.
239 // PendingStructureChanges are currently being computed.
241 // All PendingStructureChanges have successfully been computed.
242 kComplete,
243 // An error occurred when computing pending changes.
244 kFailed,
245};

Function Documentation

◆ AXTreeIDUnknown()

AX_BASE_EXPORT const AXTreeID & ui::AXTreeIDUnknown ( )

Definition at line 103 of file ax_tree_id.cc.

103 {
104 static const base::NoDestructor<AXTreeID> ax_tree_id_unknown(
106 return *ax_tree_id_unknown;
107}

◆ ClearActivePopupAxUniqueId()

AX_EXPORT void ui::ClearActivePopupAxUniqueId ( )

Definition at line 34 of file ax_active_popup.cc.

34 {
35 g_active_popup_ax_unique_id = std::nullopt;
36}
static std::optional< int32_t > g_active_popup_ax_unique_id

◆ ComputeAttribute()

AX_EXPORT std::optional< int32_t > ui::ComputeAttribute ( const ui::AXPlatformNodeDelegate delegate,
ax::mojom::IntAttribute  attribute 
)

Definition at line 98 of file compute_attributes.cc.

100 {
101 std::optional<int32_t> maybe_value = std::nullopt;
102 // Table-related nodes.
103 if (delegate->IsTableCellOrHeader())
104 maybe_value = GetCellAttribute(delegate, attribute);
105 else if (delegate->IsTableRow())
106 maybe_value = GetRowAttribute(delegate, attribute);
107 else if (delegate->IsTable())
108 maybe_value = GetTableAttribute(delegate, attribute);
109 // Ordered-set-related nodes.
110 else if (delegate->IsOrderedSetItem())
111 maybe_value = GetOrderedSetItemAttribute(delegate, attribute);
112 else if (delegate->IsOrderedSet())
113 maybe_value = GetOrderedSetAttribute(delegate, attribute);
114
115 if (!maybe_value.has_value()) {
116 return GetFromData(delegate, attribute);
117 }
118 return maybe_value;
119}
virtual bool IsOrderedSetItem() const =0
virtual bool IsTable() const =0
virtual bool IsOrderedSet() const =0
virtual bool IsTableCellOrHeader() const =0
virtual bool IsTableRow() const =0

◆ CreateTextPosition()

static AXNodePosition::AXPositionInstance ui::CreateTextPosition ( const AXNode anchor,
int  text_offset,
ax::mojom::TextAffinity  affinity 
)
static

Definition at line 225 of file ax_platform_node_textrangeprovider_win_unittest.cc.

228 {
230 anchor.id(), text_offset, affinity);
231}
virtual AXTreeID GetAXTreeID() const =0
AXID id() const
Definition: ax_node.h:110
OwnerTree * tree() const
Definition: ax_node.h:109
static AXNodePosition::AXPositionInstance CreateTextPosition(const AXNode &anchor, int text_offset, ax::mojom::TextAffinity affinity)

◆ GetActivePopupAxUniqueId()

AX_EXPORT std::optional< int32_t > ui::GetActivePopupAxUniqueId ( )

Definition at line 17 of file ax_active_popup.cc.

17 {
19}

◆ GetIA2RelationFromIntAttr()

base::string16 ui::GetIA2RelationFromIntAttr ( ax::mojom::IntAttribute  attribute)

Definition at line 40 of file ax_platform_relation_win.cc.

40 {
41 switch (attribute) {
43 return IA2_RELATION_MEMBER_OF;
45 return IA2_RELATION_ERROR;
47 // Map "popup for" to "controlled by".
48 // Unlike ATK there is no special IA2 popup-for relationship, but it can
49 // be exposed via the controlled by relation, which is also computed for
50 // content as the reverse of the controls relationship.
51 return IA2_RELATION_CONTROLLED_BY;
52 default:
53 break;
54 }
55 return base::string16();
56}

◆ GetIA2RelationFromIntListAttr()

base::string16 ui::GetIA2RelationFromIntListAttr ( ax::mojom::IntListAttribute  attribute)

Definition at line 58 of file ax_platform_relation_win.cc.

59 {
60 switch (attribute) {
62 return IA2_RELATION_CONTROLLER_FOR;
64 return IA2_RELATION_DESCRIBED_BY;
66 return IA2_RELATION_DETAILS;
68 return IA2_RELATION_FLOWS_TO;
70 return IA2_RELATION_LABELLED_BY;
71 default:
72 break;
73 }
74 return base::string16();
75}

◆ GetIA2ReverseRelationFromIntAttr()

base::string16 ui::GetIA2ReverseRelationFromIntAttr ( ax::mojom::IntAttribute  attribute)

Definition at line 77 of file ax_platform_relation_win.cc.

78 {
79 switch (attribute) {
81 return IA2_RELATION_ERROR_FOR;
82 default:
83 break;
84 }
85 return base::string16();
86}

◆ GetIA2ReverseRelationFromIntListAttr()

base::string16 ui::GetIA2ReverseRelationFromIntListAttr ( ax::mojom::IntListAttribute  attribute)

Definition at line 88 of file ax_platform_relation_win.cc.

89 {
90 switch (attribute) {
92 return IA2_RELATION_CONTROLLED_BY;
94 return IA2_RELATION_DESCRIPTION_FOR;
96 return IA2_RELATION_DETAILS_FOR;
98 return IA2_RELATION_FLOWS_FROM;
100 return IA2_RELATION_LABEL_FOR;
101 default:
102 break;
103 }
104 return base::string16();
105}

◆ HasPresentationalChildren()

AX_BASE_EXPORT bool ui::HasPresentationalChildren ( const ax::mojom::Role  role)

Definition at line 23 of file ax_role_properties.cc.

23 {
24 // See http://www.w3.org/TR/core-aam-1.1/#exclude_elements2.
25 if (IsImage(role))
26 return true;
27
28 switch (role) {
40 return true;
41 default:
42 return false;
43 }
44}
bool IsImage(const ax::mojom::Role role)

◆ INSTANTIATE_TEST_SUITE_P() [1/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextLineEndPositionWithBoundaryBehaviorCrossBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::CrossBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "NullPosition"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [2/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextLineEndPositionWithBoundaryBehaviorStopAtAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [3/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextLineEndPositionWithBoundaryBehaviorStopAtLastAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [4/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextLineEndPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [5/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextLineStartPositionWithBoundaryBehaviorCrossBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::CrossBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"NullPosition"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [6/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextLineStartPositionWithBoundaryBehaviorStopAtAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [7/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextLineStartPositionWithBoundaryBehaviorStopAtLastAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [8/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextLineStartPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextLineStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"NullPosition"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [9/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextParagraphEndPositionWithBoundaryBehaviorCrossBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::CrossBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "NullPosition"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [10/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextParagraphEndPositionWithBoundaryBehaviorStopAtAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [11/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextParagraphEndPositionWithBoundaryBehaviorStopAtLastAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [12/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextParagraphEndPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>", "TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, LINE_BREAK_ID, 0, {"TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>", "TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, LINE_BREAK_ID, 1, {"TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>", "TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [13/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextParagraphStartPositionWithBoundaryBehaviorCrossBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::CrossBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"NullPosition"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [14/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextParagraphStartPositionWithBoundaryBehaviorStopAtAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [15/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextParagraphStartPositionWithBoundaryBehaviorStopAtLastAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [16/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextParagraphStartPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextParagraphStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"NullPosition"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [17/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextWordEndPositionWithBoundaryBehaviorCrossBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::CrossBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=4 " "affinity=downstream annotated_text=Line< >1", "TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=9 text_offset=4 " "affinity=downstream annotated_text=Line< >2", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "NullPosition"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [18/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextWordEndPositionWithBoundaryBehaviorStopAtAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=4 " "affinity=downstream annotated_text=Line< >1", "TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [19/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextWordEndPositionWithBoundaryBehaviorStopAtLastAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=4 " "affinity=downstream annotated_text=Line< >1", "TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=9 text_offset=4 " "affinity=downstream annotated_text=Line< >2", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [20/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextWordEndPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=1 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=4 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=4 " "affinity=downstream annotated_text=Line< >1", "TextPosition anchor_id=5 text_offset=4 " "affinity=downstream annotated_text=Line< >1"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=4 " "affinity=downstream annotated_text=Line< >2"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [21/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextWordStartPositionWithBoundaryBehaviorCrossBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::CrossBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=5 " "affinity=downstream annotated_text=Line <1>", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=5 " "affinity=downstream annotated_text=Line <2>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=5 " "affinity=downstream annotated_text=Line <2>", "NullPosition"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [22/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextWordStartPositionWithBoundaryBehaviorStopAtAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=5 " "affinity=downstream annotated_text=Line <1>", "TextPosition anchor_id=5 text_offset=6 " "affinity=downstream annotated_text=Line 1<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=5 " "affinity=downstream annotated_text=Line <2>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [23/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextWordStartPositionWithBoundaryBehaviorStopAtLastAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>", "TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=5 " "affinity=downstream annotated_text=Line <1>", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=5 " "affinity=downstream annotated_text=Line <2>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=5 " "affinity=downstream annotated_text=Line <2>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>", "TextPosition anchor_id=9 text_offset=6 " "affinity=downstream annotated_text=Line 2<>"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [24/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreateNextWordStartPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 0, {"TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 0, {"TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, STATIC_TEXT1_ID, 1, {"TextPosition anchor_id=5 text_offset=5 " "affinity=downstream annotated_text=Line <1>", "TextPosition anchor_id=5 text_offset=5 " "affinity=downstream annotated_text=Line <1>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreateNextWordStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=5 " "affinity=downstream annotated_text=Line <2>", "TextPosition anchor_id=9 text_offset=5 " "affinity=downstream annotated_text=Line <2>"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [25/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePositionAtTextBoundary  ,
AXPositionCreatePositionAtTextBoundaryTestWithParam  ,
testing::Values(CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kCharacter, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=7 text_offset=0 affinity=downstream " "annotated_text=<\n>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kCharacter, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=8 text_offset=1 affinity=downstream " "annotated_text=L<i>ne 2"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kFormat, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=7 text_offset=0 affinity=downstream " "annotated_text=<\n>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kFormat, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=8 text_offset=6 affinity=downstream " "annotated_text=Line 2<>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineEnd, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=7 text_offset=0 affinity=downstream " "annotated_text=<\n>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineEnd, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=8 text_offset=6 affinity=downstream " "annotated_text=Line 2<>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineStart, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=6 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineStart, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "NullPosition"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineStartOrEnd, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=6 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineStartOrEnd, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=8 text_offset=6 affinity=downstream " "annotated_text=Line 2<>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kObject, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=8 text_offset=0 affinity=downstream " "annotated_text=<L>ine 2"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kObject, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=8 text_offset=6 affinity=downstream " "annotated_text=Line 2<>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphEnd, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=3 text_offset=0 affinity=downstream " "annotated_text=<>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphEnd, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=8 text_offset=6 affinity=downstream " "annotated_text=Line 2<>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphStart, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=6 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphStart, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "NullPosition"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphStartOrEnd, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=6 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphStartOrEnd, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=8 text_offset=6 affinity=downstream " "annotated_text=Line 2<>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kWebPage, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=1 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kWebPage, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=9 text_offset=6 affinity=downstream " "annotated_text=Line 2<>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordEnd, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=6 text_offset=6 affinity=downstream " "annotated_text=Line 1<>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordEnd, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=8 text_offset=4 affinity=downstream " "annotated_text=Line< >2"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordStart, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=6 text_offset=5 affinity=downstream " "annotated_text=Line <1>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordStart, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=8 text_offset=5 affinity=downstream " "annotated_text=Line <2>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordStartOrEnd, ax::mojom::MoveDirection::kBackward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=6 text_offset=5 affinity=downstream " "annotated_text=Line <1>"}, CreatePositionAtTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordStartOrEnd, ax::mojom::MoveDirection::kForward, AXBoundaryBehavior::CrossBoundary, "TextPosition anchor_id=8 text_offset=4 affinity=downstream " "annotated_text=Line< >2"})   
)

◆ INSTANTIATE_TEST_SUITE_P() [26/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousLineEndPositionWithBoundaryBehaviorCrossBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 5, {"NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 5, {"NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=6 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 0, {"TextPosition anchor_id=7 text_offset=0 " "affinity=downstream annotated_text=<\n>", "NullPosition"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [27/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousLineEndPositionWithBoundaryBehaviorStopAtAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 5, {"TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 5, {"TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 0, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [28/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousLineEndPositionWithBoundaryBehaviorStopAtLastAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 5, {"TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 5, {"TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=6 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 0, {"TextPosition anchor_id=7 text_offset=0 " "affinity=downstream annotated_text=<\n>", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [29/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousLineEndPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 12, {"TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 12, {"TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX1_ID, 2, {"NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=6 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=6 text_offset=6 " "affinity=downstream annotated_text=Line 1<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 0, {"TextPosition anchor_id=6 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=6 text_offset=6 " "affinity=downstream annotated_text=Line 1<>"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [30/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousLineStartPositionWithBoundaryBehaviorCrossBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::CrossBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=6 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "NullPosition"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [31/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousLineStartPositionWithBoundaryBehaviorStopAtAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [32/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousLineStartPositionWithBoundaryBehaviorStopAtLastAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=6 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "TextPosition anchor_id=6 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [33/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousLineStartPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousLineStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [34/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousParagraphEndPositionWithBoundaryBehaviorCrossBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 5, {"TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 5, {"TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>", "TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 0, {"TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>", "NullPosition"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [35/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousParagraphEndPositionWithBoundaryBehaviorStopAtAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 5, {"TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 5, {"TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 0, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [36/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousParagraphEndPositionWithBoundaryBehaviorStopAtLastAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 5, {"TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 5, {"TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>", "TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 0, {"TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [37/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousParagraphEndPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 12, {"TextPosition anchor_id=1 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 12, {"TextPosition anchor_id=4 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=7 " "affinity=upstream annotated_text=Line 1\n<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX1_ID, 2, {"TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>", "TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 0, {"TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>", "TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, LINE_BREAK_ID, 0, {"TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=3 text_offset=0 " "affinity=downstream annotated_text=<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, LINE_BREAK_ID, 1, {"TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>", "TextPosition anchor_id=7 text_offset=1 " "affinity=downstream annotated_text=\n<>"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [38/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousParagraphStartPositionWithBoundaryBehaviorCrossBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::CrossBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=6 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "NullPosition"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [39/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousParagraphStartPositionWithBoundaryBehaviorStopAtAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [40/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousParagraphStartPositionWithBoundaryBehaviorStopAtLastAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=6 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "TextPosition anchor_id=6 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [41/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousParagraphStartPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousParagraphStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [42/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousWordEndPositionWithBoundaryBehaviorCrossBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::CrossBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=4 " "affinity=downstream annotated_text=Line< >1", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=6 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=6 text_offset=4 " "affinity=downstream annotated_text=Line< >1", "NullPosition"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [43/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousWordEndPositionWithBoundaryBehaviorStopAtAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 13, { "TextPosition anchor_id=1 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", }}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=4 " "affinity=downstream annotated_text=Line< >1", "TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [44/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousWordEndPositionWithBoundaryBehaviorStopAtLastAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=1 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=1 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=11 " "affinity=downstream annotated_text=Line 1\nLine< >2", "TextPosition anchor_id=4 text_offset=6 " "affinity=downstream annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=4 " "affinity=downstream annotated_text=Line< >1\nLine 2", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=4 " "affinity=downstream annotated_text=Line< >1", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=6 text_offset=6 " "affinity=downstream annotated_text=Line 1<>", "TextPosition anchor_id=6 text_offset=4 " "affinity=downstream annotated_text=Line< >1", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>", "TextPosition anchor_id=2 text_offset=0 " "affinity=downstream annotated_text=<>"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [45/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousWordEndPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=13 " "affinity=downstream annotated_text=Line 1\nLine 2<>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=4 " "affinity=downstream annotated_text=Line< >1", "TextPosition anchor_id=5 text_offset=4 " "affinity=downstream annotated_text=Line< >1"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordEndPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=4 " "affinity=downstream annotated_text=Line< >2"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [46/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousWordStartPositionWithBoundaryBehaviorCrossBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::CrossBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::CrossBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::CrossBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "NullPosition"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::CrossBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=6 text_offset=5 " "affinity=downstream annotated_text=Line <1>", "TextPosition anchor_id=6 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "NullPosition"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [47/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousWordStartPositionWithBoundaryBehaviorStopAtAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopAtAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [48/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousWordStartPositionWithBoundaryBehaviorStopAtLastAnchorBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=1 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=1 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=1 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=4 text_offset=7 " "affinity=downstream annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=5 " "affinity=downstream annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1\nLine 2"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "TextPosition anchor_id=5 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopAtLastAnchorBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=6 text_offset=5 " "affinity=downstream annotated_text=Line <1>", "TextPosition anchor_id=6 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1", "TextPosition anchor_id=6 text_offset=0 " "affinity=downstream annotated_text=<L>ine 1"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [49/50]

ui::INSTANTIATE_TEST_SUITE_P ( CreatePreviousWordStartPositionWithBoundaryBehaviorStopIfAlreadyAtBoundary  ,
AXPositionTextNavigationTestWithParam  ,
testing::Values(TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, ROOT_ID, 13, {"TextPosition anchor_id=1 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=1 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, TEXT_FIELD_ID, 13, {"TextPosition anchor_id=4 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>", "TextPosition anchor_id=4 text_offset=12 " "affinity=downstream annotated_text=Line 1\nLine <2>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, STATIC_TEXT1_ID, 5, {"TextPosition anchor_id=5 text_offset=5 " "affinity=downstream annotated_text=Line <1>"}}, TextNavigationTestParam{[](const TestPositionType &position) { return position->CreatePreviousWordStartPosition(AXBoundaryBehavior::StopIfAlreadyAtBoundary);}, INLINE_BOX2_ID, 4, {"TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2", "TextPosition anchor_id=9 text_offset=0 " "affinity=downstream annotated_text=<L>ine 2"}})   
)

◆ INSTANTIATE_TEST_SUITE_P() [50/50]

ui::INSTANTIATE_TEST_SUITE_P ( ExpandToEnclosingTextBoundary  ,
AXPositionExpandToEnclosingTextBoundaryTestWithParam  ,
testing::Values(ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kCharacter, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=6 affinity=downstream " "annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=7 affinity=downstream " "annotated_text=Line 1\n<L>ine 2"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kCharacter, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=7 affinity=downstream " "annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=8 affinity=downstream " "annotated_text=Line 1\nL<i>ne 2"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kFormat, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=13 affinity=downstream " "annotated_text=Line 1\nLine 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kFormat, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=13 affinity=downstream " "annotated_text=Line 1\nLine 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineEnd, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=6 affinity=downstream " "annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=13 affinity=downstream " "annotated_text=Line 1\nLine 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineEnd, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=6 affinity=downstream " "annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=13 affinity=downstream " "annotated_text=Line 1\nLine 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineStart, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=7 affinity=downstream " "annotated_text=Line 1\n<L>ine 2"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineStart, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=7 affinity=downstream " "annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 affinity=downstream " "annotated_text=Line 1\nLine 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineStartOrEnd, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=6 affinity=downstream " "annotated_text=Line 1<\n>Line 2"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kLineStartOrEnd, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=7 affinity=downstream " "annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 affinity=downstream " "annotated_text=Line 1\nLine 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kObject, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=13 affinity=downstream " "annotated_text=Line 1\nLine 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kObject, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=13 affinity=downstream " "annotated_text=Line 1\nLine 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphEnd, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=7 affinity=upstream " "annotated_text=Line 1\n<L>ine 2"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphEnd, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=7 affinity=upstream " "annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 affinity=downstream " "annotated_text=Line 1\nLine 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphStart, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=7 affinity=downstream " "annotated_text=Line 1\n<L>ine 2"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphStart, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=7 affinity=downstream " "annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 affinity=downstream " "annotated_text=Line 1\nLine 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphStartOrEnd, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=4 text_offset=7 affinity=upstream " "annotated_text=Line 1\n<L>ine 2"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kParagraphStartOrEnd, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=7 affinity=downstream " "annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=13 affinity=downstream " "annotated_text=Line 1\nLine 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kWebPage, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=1 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=9 text_offset=6 affinity=downstream " "annotated_text=Line 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kWebPage, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=1 text_offset=0 affinity=downstream " "annotated_text=<L>ine 1\nLine 2", "TextPosition anchor_id=9 text_offset=6 affinity=downstream " "annotated_text=Line 2<>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordEnd, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=6 affinity=downstream " "annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=11 affinity=downstream " "annotated_text=Line 1\nLine< >2"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordEnd, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=6 affinity=downstream " "annotated_text=Line 1<\n>Line 2", "TextPosition anchor_id=4 text_offset=11 affinity=downstream " "annotated_text=Line 1\nLine< >2"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordStart, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=5 affinity=downstream " "annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=4 text_offset=7 affinity=downstream " "annotated_text=Line 1\n<L>ine 2"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordStart, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=7 affinity=downstream " "annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=12 affinity=downstream " "annotated_text=Line 1\nLine <2>"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordStartOrEnd, AXRangeExpandBehavior::kLeftFirst, "TextPosition anchor_id=4 text_offset=5 affinity=downstream " "annotated_text=Line <1>\nLine 2", "TextPosition anchor_id=4 text_offset=6 affinity=downstream " "annotated_text=Line 1<\n>Line 2"}, ExpandToEnclosingTextBoundaryTestParam{ ax::mojom::TextBoundary::kWordStartOrEnd, AXRangeExpandBehavior::kRightFirst, "TextPosition anchor_id=4 text_offset=7 affinity=downstream " "annotated_text=Line 1\n<L>ine 2", "TextPosition anchor_id=4 text_offset=11 affinity=downstream " "annotated_text=Line 1\nLine< >2"})   
)

◆ IsAlert()

AX_BASE_EXPORT bool ui::IsAlert ( const ax::mojom::Role  role)

Definition at line 46 of file ax_role_properties.cc.

46 {
47 switch (role) {
50 return true;
51 default:
52 return false;
53 }
54}

◆ IsButton()

AX_BASE_EXPORT bool ui::IsButton ( const ax::mojom::Role  role)

Definition at line 56 of file ax_role_properties.cc.

56 {
57 // According to the WAI-ARIA spec, native button or role="button"
58 // supports |aria-expanded| and |aria-pressed|.
59 // If the button has |aria-expanded| set, then it takes on
60 // Role::kPopUpButton.
61 // If the button has |aria-pressed| set, then it takes on
62 // Role::kToggleButton.
63 // https://www.w3.org/TR/wai-aria-1.1/#button
64 return role == ax::mojom::Role::kButton ||
67}

◆ IsCellOrTableHeader()

AX_BASE_EXPORT bool ui::IsCellOrTableHeader ( const ax::mojom::Role  role)

Definition at line 110 of file ax_role_properties.cc.

110 {
111 switch (role) {
115 return true;
117 return kExposeLayoutTableAsDataTable;
118 default:
119 return false;
120 }
121}

◆ IsClickable()

AX_BASE_EXPORT bool ui::IsClickable ( const ax::mojom::Role  role)

Definition at line 69 of file ax_role_properties.cc.

69 {
70 switch (role) {
101 // kTree and related roles are not included because they are not natively
102 // supported by HTML and so their "clickable" behavior is uncertain.
104 return true;
105 default:
106 return false;
107 }
108}

◆ IsContainerWithSelectableChildren()

AX_BASE_EXPORT bool ui::IsContainerWithSelectableChildren ( const ax::mojom::Role  role)

◆ IsControl()

AX_BASE_EXPORT bool ui::IsControl ( const ax::mojom::Role  role)

◆ IsControlOnAndroid()

AX_BASE_EXPORT bool ui::IsControlOnAndroid ( const ax::mojom::Role  role,
bool  isFocusable 
)

Definition at line 179 of file ax_role_properties.cc.

179 {
180 switch (role) {
182 return isFocusable;
192 return true;
200 return false;
201 default:
202 return IsControl(role);
203 }
204}
bool IsControl(const ax::mojom::Role role)

◆ IsDialog()

AX_BASE_EXPORT bool ui::IsDialog ( const ax::mojom::Role  role)

Definition at line 217 of file ax_role_properties.cc.

217 {
218 switch (role) {
221 return true;
222 default:
223 return false;
224 }
225}

◆ IsDocument()

AX_BASE_EXPORT bool ui::IsDocument ( const ax::mojom::Role  role)

Definition at line 206 of file ax_role_properties.cc.

206 {
207 switch (role) {
211 return true;
212 default:
213 return false;
214 }
215}

◆ IsForm()

AX_BASE_EXPORT bool ui::IsForm ( const ax::mojom::Role  role)

Definition at line 227 of file ax_role_properties.cc.

227 {
228 switch (role) {
230 return true;
231 default:
232 return false;
233 }
234}

◆ IsFormatBoundary()

AX_BASE_EXPORT bool ui::IsFormatBoundary ( const ax::mojom::Role  role)

Definition at line 236 of file ax_role_properties.cc.

236 {
237 return IsControl(role) || IsHeading(role) || IsImageOrVideo(role);
238}
bool IsImageOrVideo(const ax::mojom::Role role)
bool IsHeading(const ax::mojom::Role role)

◆ IsHeading()

AX_BASE_EXPORT bool ui::IsHeading ( const ax::mojom::Role  role)

Definition at line 240 of file ax_role_properties.cc.

240 {
241 switch (role) {
244 return true;
245 default:
246 return false;
247 }
248}

◆ IsHeadingOrTableHeader()

AX_BASE_EXPORT bool ui::IsHeadingOrTableHeader ( const ax::mojom::Role  role)

Definition at line 250 of file ax_role_properties.cc.

250 {
251 switch (role) {
256 return true;
257 default:
258 return false;
259 }
260}

◆ IsIframe()

AX_BASE_EXPORT bool ui::IsIframe ( ax::mojom::Role  role)

Definition at line 262 of file ax_role_properties.cc.

262 {
263 switch (role) {
266 return true;
267 default:
268 return false;
269 }
270}

◆ IsImage()

AX_BASE_EXPORT bool ui::IsImage ( const ax::mojom::Role  role)

Definition at line 276 of file ax_role_properties.cc.

276 {
277 switch (role) {
284 return true;
285 default:
286 return false;
287 }
288}

◆ IsImageOrVideo()

AX_BASE_EXPORT bool ui::IsImageOrVideo ( const ax::mojom::Role  role)

Definition at line 272 of file ax_role_properties.cc.

272 {
273 return IsImage(role) || role == ax::mojom::Role::kVideo;
274}

◆ IsItemLike()

AX_BASE_EXPORT bool ui::IsItemLike ( const ax::mojom::Role  role)

◆ IsLandmark()

AX_BASE_EXPORT bool ui::IsLandmark ( const ax::mojom::Role  role)

Definition at line 311 of file ax_role_properties.cc.

311 {
312 switch (role) {
321 return true;
322 default:
323 return false;
324 }
325}

◆ IsLink()

AX_BASE_EXPORT bool ui::IsLink ( const ax::mojom::Role  role)

Definition at line 327 of file ax_role_properties.cc.

327 {
328 switch (role) {
334 return true;
335 default:
336 return false;
337 }
338}

◆ IsList()

AX_BASE_EXPORT bool ui::IsList ( const ax::mojom::Role  role)

Definition at line 340 of file ax_role_properties.cc.

340 {
341 switch (role) {
348 return true;
349 default:
350 return false;
351 }
352}

◆ IsListItem()

AX_BASE_EXPORT bool ui::IsListItem ( const ax::mojom::Role  role)

Definition at line 354 of file ax_role_properties.cc.

354 {
355 switch (role) {
362 return true;
363 default:
364 return false;
365 }
366}

◆ IsMenuItem()

AX_BASE_EXPORT bool ui::IsMenuItem ( ax::mojom::Role  role)

Definition at line 368 of file ax_role_properties.cc.

368 {
369 switch (role) {
373 return true;
374 default:
375 return false;
376 }
377}

◆ IsMenuRelated()

AX_BASE_EXPORT bool ui::IsMenuRelated ( const ax::mojom::Role  role)

Definition at line 379 of file ax_role_properties.cc.

379 {
380 switch (role) {
388 return true;
389 default:
390 return false;
391 }
392}

◆ IsNameExposedInAXValueForRole()

bool ui::IsNameExposedInAXValueForRole ( ax::mojom::Role  role)

Definition at line 1134 of file ax_platform_node_mac.mm.

1134 {
1135 switch (role) {
1141 return true;
1142 default:
1143 return false;
1144 }
1145}

◆ IsNodeIdIntAttribute()

AX_BASE_EXPORT bool ui::IsNodeIdIntAttribute ( ax::mojom::IntAttribute  attr)

Definition at line 99 of file ax_node_data.cc.

99 {
100 switch (attr) {
113 return true;
114
115 // Note: all of the attributes are included here explicitly,
116 // rather than using "default:", so that it's a compiler error to
117 // add a new attribute without explicitly considering whether it's
118 // a node id attribute or not.
168 return false;
169 }
170
172 return false;
173}
#define BASE_UNREACHABLE()
Definition: logging.h:69

◆ IsNodeIdIntListAttribute()

AX_BASE_EXPORT bool ui::IsNodeIdIntListAttribute ( ax::mojom::IntListAttribute  attr)

Definition at line 177 of file ax_node_data.cc.

177 {
178 switch (attr) {
186 return true;
187
188 // Note: all of the attributes are included here explicitly,
189 // rather than using "default:", so that it's a compiler error to
190 // add a new attribute without explicitly considering whether it's
191 // a node id attribute or not.
201 return false;
202 }
203
205 return false;
206}

◆ IsPresentational()

AX_BASE_EXPORT bool ui::IsPresentational ( const ax::mojom::Role  role)

Definition at line 394 of file ax_role_properties.cc.

394 {
395 switch (role) {
398 return true;
399 default:
400 return false;
401 }
402}

◆ IsRadio()

AX_BASE_EXPORT bool ui::IsRadio ( const ax::mojom::Role  role)

Definition at line 404 of file ax_role_properties.cc.

404 {
405 switch (role) {
408 return true;
409 default:
410 return false;
411 }
412}

◆ IsRangeValueSupported()

AX_BASE_EXPORT bool ui::IsRangeValueSupported ( const ax::mojom::Role  role)

Definition at line 414 of file ax_role_properties.cc.

414 {
415 // https://www.w3.org/TR/wai-aria-1.1/#aria-valuenow
416 // https://www.w3.org/TR/wai-aria-1.1/#aria-valuetext
417 // Roles that support aria-valuetext / aria-valuenow
418 switch (role) {
425 return true;
426 default:
427 return false;
428 }
429}

◆ IsReadOnlySupported()

AX_BASE_EXPORT bool ui::IsReadOnlySupported ( const ax::mojom::Role  role)

Definition at line 431 of file ax_role_properties.cc.

431 {
432 // https://www.w3.org/TR/wai-aria-1.1/#aria-readonly
433 // Roles that support aria-readonly
434 switch (role) {
458 return true;
459
460 // https://www.w3.org/TR/wai-aria-1.1/#aria-readonly
461 // ARIA-1.1+ 'gridcell', supports aria-readonly, but 'cell' does not.
462 //
463 // https://www.w3.org/TR/wai-aria-1.1/#columnheader
464 // https://www.w3.org/TR/wai-aria-1.1/#rowheader
465 // While the [columnheader|rowheader] role can be used in both interactive
466 // grids and non-interactive tables, the use of aria-readonly and
467 // aria-required is only applicable to interactive elements.
468 // Therefore, [...] user agents SHOULD NOT expose either property to
469 // assistive technologies unless the columnheader descends from a grid.
473 return false;
474 default:
475 return false;
476 }
477}

◆ IsRowContainer()

AX_BASE_EXPORT bool ui::IsRowContainer ( const ax::mojom::Role  role)

Definition at line 479 of file ax_role_properties.cc.

479 {
480 switch (role) {
486 return true;
488 return kExposeLayoutTableAsDataTable;
489 default:
490 return false;
491 }
492}

◆ IsSection()

AX_BASE_EXPORT bool ui::IsSection ( const ax::mojom::Role  role)

Definition at line 494 of file ax_role_properties.cc.

494 {
495 if (IsLandmark(role) || IsSelect(role))
496 return true;
497
498 switch (role) {
500 case ax::mojom::Role::kAlertDialog: // Subclass of kAlert.
502 case ax::mojom::Role::kColumnHeader: // Subclass of kCell.
504 case ax::mojom::Role::kDirectory: // Subclass of kList.
505 case ax::mojom::Role::kFeed: // Subclass of kList.
507 case ax::mojom::Role::kGrid: // Subclass of kTable.
516 case ax::mojom::Role::kProgressIndicator: // Subclass of kStatus.
517 case ax::mojom::Role::kRow: // Subclass of kGroup.
518 case ax::mojom::Role::kRowHeader: // Subclass of kCell.
524 case ax::mojom::Role::kTimer: // Subclass of kStatus.
525 case ax::mojom::Role::kToolbar: // Subclass of kGroup.
527 case ax::mojom::Role::kTreeItem: // Subclass of kListItem.
528 return true;
529 default:
530 return false;
531 }
532}
bool IsSelect(const ax::mojom::Role role)
bool IsLandmark(const ax::mojom::Role role)

◆ IsSectionhead()

AX_BASE_EXPORT bool ui::IsSectionhead ( const ax::mojom::Role  role)

Definition at line 534 of file ax_role_properties.cc.

534 {
535 switch (role) {
540 return true;
541 default:
542 return false;
543 }
544}

◆ IsSelect()

AX_BASE_EXPORT bool ui::IsSelect ( const ax::mojom::Role  role)

Definition at line 546 of file ax_role_properties.cc.

546 {
547 switch (role) {
551 case ax::mojom::Role::kMenuBar: // Subclass of kMenu.
554 case ax::mojom::Role::kTreeGrid: // Subclass of kTree.
555 return true;
556 default:
557 return false;
558 }
559}

◆ IsSetLike()

AX_BASE_EXPORT bool ui::IsSetLike ( const ax::mojom::Role  role)

Definition at line 561 of file ax_role_properties.cc.

◆ IsStaticList()

AX_BASE_EXPORT bool ui::IsStaticList ( const ax::mojom::Role  role)

Definition at line 584 of file ax_role_properties.cc.

584 {
585 switch (role) {
588 return true;
589 default:
590 return false;
591 }
592}

◆ IsStructure()

AX_BASE_EXPORT bool ui::IsStructure ( const ax::mojom::Role  role)

Definition at line 594 of file ax_role_properties.cc.

594 {
595 if (IsSection(role) || IsSectionhead(role))
596 return true;
597
598 switch (role) {
601 case ax::mojom::Role::kArticle: // Subclass of kDocument.
605 // Dpub roles.
640 return true;
641 default:
642 return false;
643 }
644}
bool IsSection(const ax::mojom::Role role)
bool IsSectionhead(const ax::mojom::Role role)

◆ IsTableColumn()

AX_BASE_EXPORT bool ui::IsTableColumn ( ax::mojom::Role  role)

Definition at line 646 of file ax_role_properties.cc.

646 {
647 return role == ax::mojom::Role::kColumn;
648}

◆ IsTableHeader()

AX_BASE_EXPORT bool ui::IsTableHeader ( ax::mojom::Role  role)

Definition at line 650 of file ax_role_properties.cc.

650 {
651 switch (role) {
654 return true;
655 default:
656 return false;
657 }
658}

◆ IsTableLike()

AX_BASE_EXPORT bool ui::IsTableLike ( const ax::mojom::Role  role)

Definition at line 660 of file ax_role_properties.cc.

660 {
661 switch (role) {
666 return true;
668 return kExposeLayoutTableAsDataTable;
669 default:
670 return false;
671 }
672}

◆ IsTableRow()

AX_BASE_EXPORT bool ui::IsTableRow ( ax::mojom::Role  role)

Definition at line 674 of file ax_role_properties.cc.

674 {
675 switch (role) {
677 return true;
679 return kExposeLayoutTableAsDataTable;
680 default:
681 return false;
682 }
683}

◆ IsText()

AX_BASE_EXPORT bool ui::IsText ( ax::mojom::Role  role)

Definition at line 685 of file ax_role_properties.cc.

685 {
686 switch (role) {
693 return true;
694 default:
695 return false;
696 }
697}

◆ IsValuePatternSupported()

AX_EXPORT bool ui::IsValuePatternSupported ( AXPlatformNodeDelegate delegate)

Definition at line 14 of file ax_platform_node_delegate_utils_win.cc.

14 {
15 // https://docs.microsoft.com/en-us/windows/desktop/winauto/uiauto-implementingvalue
16 // The Value control pattern is used to support controls that have an
17 // intrinsic value not spanning a range and that can be represented as
18 // a string.
19 //
20 // IValueProvider must be implemented by controls such as the color picker
21 // selection control [...]
22
23 // https://www.w3.org/TR/html-aam-1.0/
24 // The HTML AAM maps "href [a; area]" to UIA Value.Value
25 return delegate->GetData().IsRangeValueSupported() ||
26 IsReadOnlySupported(delegate->GetData().role) ||
27 IsLink(delegate->GetData().role) ||
29 delegate->IsCellOrHeaderOfARIAGrid();
30}
virtual bool IsCellOrHeaderOfARIAGrid() const =0
virtual const AXNodeData & GetData() const =0
bool IsReadOnlySupported(const ax::mojom::Role role)
bool IsLink(const ax::mojom::Role role)
bool IsRangeValueSupported() const
ax::mojom::Role role
Definition: ax_node_data.h:277

◆ kAXModeComplete()

◆ kAXModeWebContentsOnly()

static constexpr AXMode ui::kAXModeWebContentsOnly ( AXMode::kWebContents|AXMode::kInlineTextBoxes|AXMode::kScreenReader|AXMode::kHTML  )
staticconstexpr

◆ operator!=() [1/3]

bool ui::operator!= ( const AXEventIntent a,
const AXEventIntent b 
)

Definition at line 31 of file ax_event_intent.cc.

31 {
32 return !(a == b);
33}
static bool b
struct MyStruct a[10]

◆ operator!=() [2/3]

template<class AXPositionType , class AXNodeType >
bool ui::operator!= ( const AXPosition< AXPositionType, AXNodeType > &  first,
const AXPosition< AXPositionType, AXNodeType > &  second 
)

Definition at line 3987 of file ax_position.h.

3988 {
3989 const std::optional<int> compare_to_optional = first.CompareTo(second);
3990 return compare_to_optional.has_value() && compare_to_optional.value() != 0;
3991}
std::optional< int > CompareTo(const AXPosition &other) const
Definition: ax_position.h:2833

◆ operator!=() [3/3]

AX_EXPORT bool ui::operator!= ( const AXTreeData lhs,
const AXTreeData rhs 
)

Definition at line 86 of file ax_tree_data.cc.

86 {
87 return !(lhs == rhs);
88}

◆ operator<()

template<class AXPositionType , class AXNodeType >
bool ui::operator< ( const AXPosition< AXPositionType, AXNodeType > &  first,
const AXPosition< AXPositionType, AXNodeType > &  second 
)

Definition at line 3994 of file ax_position.h.

3995 {
3996 const std::optional<int> compare_to_optional = first.CompareTo(second);
3997 return compare_to_optional.has_value() && compare_to_optional.value() < 0;
3998}

◆ operator<<() [1/8]

AX_EXPORT std::ostream & ui::operator<< ( std::ostream &  os,
AXEventGenerator::Event  event 
)

Definition at line 917 of file ax_event_generator.cc.

917 {
918 return os << ToString(event);
919}
FlKeyEvent * event
const char * ToString(AXEventGenerator::Event event)

◆ operator<<() [2/8]

std::ostream & ui::operator<< ( std::ostream &  stream,
AXPlatformNode node 
)

Definition at line 63 of file ax_platform_node.cc.

63 {
64 return stream << node.ToString();
65}
std::string ToString()

◆ operator<<() [3/8]

AX_BASE_EXPORT std::ostream & ui::operator<< ( std::ostream &  stream,
const AXMode mode 
)

Definition at line 14 of file ax_mode.cc.

14 {
15 return stream << mode.ToString();
16}
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition: switches.h:228

◆ operator<<() [4/8]

AX_EXPORT std::ostream & ui::operator<< ( std::ostream &  stream,
const AXNode node 
)

Definition at line 536 of file ax_node.cc.

536 {
537 return stream << node.data().ToString();
538}
const AXNodeData & data() const
Definition: ax_node.h:112
virtual std::string ToString() const

◆ operator<<() [5/8]

template<class AXPositionType , class AXNodeType >
std::ostream & ui::operator<< ( std::ostream &  stream,
const AXPosition< AXPositionType, AXNodeType > &  position 
)

Definition at line 4028 of file ax_position.h.

4030 {
4031 return stream << position.ToString();
4032}
std::string ToString() const
Definition: ax_position.h:265

◆ operator<<() [6/8]

template<class AXPositionType >
std::ostream & ui::operator<< ( std::ostream &  stream,
const AXRange< AXPositionType > &  range 
)

Definition at line 425 of file ax_range.h.

426 {
427 return stream << range.ToString();
428}
std::string ToString() const
Definition: ax_range.h:155

◆ operator<<() [7/8]

AX_BASE_EXPORT std::ostream & ui::operator<< ( std::ostream &  stream,
const AXRelativeBounds bounds 
)

Definition at line 72 of file ax_relative_bounds.cc.

72 {
73 return stream << bounds.ToString();
74}
Optional< SkRect > bounds
Definition: SkRecords.h:189

◆ operator<<() [8/8]

AX_BASE_EXPORT std::ostream & ui::operator<< ( std::ostream &  stream,
const AXTreeID value 
)

Definition at line 99 of file ax_tree_id.cc.

99 {
100 return stream << value.ToString();
101}
uint8_t value

◆ operator<=()

template<class AXPositionType , class AXNodeType >
bool ui::operator<= ( const AXPosition< AXPositionType, AXNodeType > &  first,
const AXPosition< AXPositionType, AXNodeType > &  second 
)

Definition at line 4001 of file ax_position.h.

4002 {
4003 const std::optional<int> compare_to_optional = first.CompareTo(second);
4004 return compare_to_optional.has_value() && compare_to_optional.value() <= 0;
4005}

◆ operator==() [1/3]

bool ui::operator== ( const AXEventIntent a,
const AXEventIntent b 
)

Definition at line 26 of file ax_event_intent.cc.

26 {
27 return a.command == b.command && a.text_boundary == b.text_boundary &&
28 a.move_direction == b.move_direction;
29}

◆ operator==() [2/3]

template<class AXPositionType , class AXNodeType >
bool ui::operator== ( const AXPosition< AXPositionType, AXNodeType > &  first,
const AXPosition< AXPositionType, AXNodeType > &  second 
)

Definition at line 3980 of file ax_position.h.

3981 {
3982 const std::optional<int> compare_to_optional = first.CompareTo(second);
3983 return compare_to_optional.has_value() && compare_to_optional.value() == 0;
3984}

◆ operator==() [3/3]

AX_EXPORT bool ui::operator== ( const AXTreeData lhs,
const AXTreeData rhs 
)

Definition at line 70 of file ax_tree_data.cc.

70 {
71 return (lhs.tree_id == rhs.tree_id &&
72 lhs.parent_tree_id == rhs.parent_tree_id &&
74 lhs.doctype == rhs.doctype && lhs.loaded == rhs.loaded &&
76 lhs.mimetype == rhs.mimetype && lhs.title == rhs.title &&
77 lhs.url == rhs.url && lhs.focus_id == rhs.focus_id &&
84}
std::string url
Definition: ax_tree_data.h:49
AXNode::AXID sel_anchor_object_id
Definition: ax_tree_data.h:62
AXTreeID focused_tree_id
Definition: ax_tree_data.h:41
ax::mojom::TextAffinity sel_focus_affinity
Definition: ax_tree_data.h:67
AXNode::AXID sel_focus_object_id
Definition: ax_tree_data.h:65
std::string mimetype
Definition: ax_tree_data.h:47
std::string doctype
Definition: ax_tree_data.h:44
AXNode::AXID focus_id
Definition: ax_tree_data.h:53
int32_t sel_focus_offset
Definition: ax_tree_data.h:66
ax::mojom::TextAffinity sel_anchor_affinity
Definition: ax_tree_data.h:64
AXTreeID parent_tree_id
Definition: ax_tree_data.h:37
std::string title
Definition: ax_tree_data.h:48
AXTreeID tree_id
Definition: ax_tree_data.h:34
float loading_progress
Definition: ax_tree_data.h:46
int32_t sel_anchor_offset
Definition: ax_tree_data.h:63

◆ operator>()

template<class AXPositionType , class AXNodeType >
bool ui::operator> ( const AXPosition< AXPositionType, AXNodeType > &  first,
const AXPosition< AXPositionType, AXNodeType > &  second 
)

Definition at line 4008 of file ax_position.h.

4009 {
4010 const std::optional<int> compare_to_optional = first.CompareTo(second);
4011 return compare_to_optional.has_value() && compare_to_optional.value() > 0;
4012}

◆ operator>=()

template<class AXPositionType , class AXNodeType >
bool ui::operator>= ( const AXPosition< AXPositionType, AXNodeType > &  first,
const AXPosition< AXPositionType, AXNodeType > &  second 
)

Definition at line 4015 of file ax_position.h.

4016 {
4017 const std::optional<int> compare_to_optional = first.CompareTo(second);
4018 return compare_to_optional.has_value() && compare_to_optional.value() >= 0;
4019}

◆ ParseAction()

AX_BASE_EXPORT ax::mojom::Action ui::ParseAction ( const char *  action)

Definition at line 1189 of file ax_enum_util.cc.

1189 {
1190 if (0 == strcmp(action, "none"))
1192 if (0 == strcmp(action, "annotatePageImages"))
1194 if (0 == strcmp(action, "blur"))
1196 if (0 == strcmp(action, "clearAccessibilityFocus"))
1198 if (0 == strcmp(action, "collapse"))
1200 if (0 == strcmp(action, "customAction"))
1202 if (0 == strcmp(action, "decrement"))
1204 if (0 == strcmp(action, "doDefault"))
1206 if (0 == strcmp(action, "expand"))
1208 if (0 == strcmp(action, "focus"))
1210 if (0 == strcmp(action, "getImageData"))
1212 if (0 == strcmp(action, "getTextLocation"))
1214 if (0 == strcmp(action, "hitTest"))
1216 if (0 == strcmp(action, "increment"))
1218 if (0 == strcmp(action, "loadInlineTextBoxes"))
1220 if (0 == strcmp(action, "replaceSelectedText"))
1222 if (0 == strcmp(action, "scrollBackward"))
1224 if (0 == strcmp(action, "scrollForward"))
1226 if (0 == strcmp(action, "scrollUp"))
1228 if (0 == strcmp(action, "scrollDown"))
1230 if (0 == strcmp(action, "scrollLeft"))
1232 if (0 == strcmp(action, "scrollRight"))
1234 if (0 == strcmp(action, "scrollToMakeVisible"))
1236 if (0 == strcmp(action, "scrollToPoint"))
1238 if (0 == strcmp(action, "setAccessibilityFocus"))
1240 if (0 == strcmp(action, "setScrollOffset"))
1242 if (0 == strcmp(action, "setSelection"))
1244 if (0 == strcmp(action, "setSequentialFocusNavigationStartingPoint"))
1246 if (0 == strcmp(action, "setValue"))
1248 if (0 == strcmp(action, "showContextMenu"))
1250 if (0 == strcmp(action, "signalEndOfTest"))
1252 if (0 == strcmp(action, "showTooltip"))
1254 if (0 == strcmp(action, "hideTooltip"))
1256 if (0 == strcmp(action, "internalInvalidateTree"))
1259}
@ kSetSequentialFocusNavigationStartingPoint

◆ ParseActionFlags()

AX_BASE_EXPORT ax::mojom::ActionFlags ui::ParseActionFlags ( const char *  action_flags)

Definition at line 1274 of file ax_enum_util.cc.

1274 {
1275 if (0 == strcmp(action_flags, "none"))
1277 if (0 == strcmp(action_flags, "requestImages"))
1279 if (0 == strcmp(action_flags, "requestInlineTextBoxes"))
1282}

◆ ParseAriaCurrentState()

AX_BASE_EXPORT ax::mojom::AriaCurrentState ui::ParseAriaCurrentState ( const char *  aria_current_state)

Definition at line 2438 of file ax_enum_util.cc.

2439 {
2440 if (0 == strcmp(aria_current_state, "none"))
2442 if (0 == strcmp(aria_current_state, "false"))
2444 if (0 == strcmp(aria_current_state, "true"))
2446 if (0 == strcmp(aria_current_state, "page"))
2448 if (0 == strcmp(aria_current_state, "step"))
2450 if (0 == strcmp(aria_current_state, "location"))
2452 if (0 == strcmp(aria_current_state, "unclippedLocation"))
2454 if (0 == strcmp(aria_current_state, "date"))
2456 if (0 == strcmp(aria_current_state, "time"))
2459}

◆ ParseBoolAttribute()

AX_BASE_EXPORT ax::mojom::BoolAttribute ui::ParseBoolAttribute ( const char *  bool_attribute)

Definition at line 1872 of file ax_enum_util.cc.

1872 {
1873 if (0 == strcmp(bool_attribute, "none"))
1875 if (0 == strcmp(bool_attribute, "busy"))
1877 if (0 == strcmp(bool_attribute, "editableRoot"))
1879 if (0 == strcmp(bool_attribute, "containerLiveAtomic"))
1881 if (0 == strcmp(bool_attribute, "containerLiveBusy"))
1883 if (0 == strcmp(bool_attribute, "grabbed"))
1885 if (0 == strcmp(bool_attribute, "liveAtomic"))
1887 if (0 == strcmp(bool_attribute, "modal"))
1889 if (0 == strcmp(bool_attribute, "updateLocationOnly"))
1891 if (0 == strcmp(bool_attribute, "canvasHasFallback"))
1893 if (0 == strcmp(bool_attribute, "scrollable"))
1895 if (0 == strcmp(bool_attribute, "clickable"))
1897 if (0 == strcmp(bool_attribute, "clipsChildren"))
1899 if (0 == strcmp(bool_attribute, "notUserSelectableStyle"))
1901 if (0 == strcmp(bool_attribute, "selected"))
1903 if (0 == strcmp(bool_attribute, "selectedFromFocus"))
1905 if (0 == strcmp(bool_attribute, "supportsTextLocation"))
1907 if (0 == strcmp(bool_attribute, "isLineBreakingObject"))
1909 if (0 == strcmp(bool_attribute, "isPageBreakingObject"))
1911 if (0 == strcmp(bool_attribute, "hasAriaAttribute"))
1914}

◆ ParseCheckedState()

AX_BASE_EXPORT ax::mojom::CheckedState ui::ParseCheckedState ( const char *  checked_state)

Definition at line 2564 of file ax_enum_util.cc.

2564 {
2565 if (0 == strcmp(checked_state, "none"))
2567 if (0 == strcmp(checked_state, "false"))
2569 if (0 == strcmp(checked_state, "true"))
2571 if (0 == strcmp(checked_state, "mixed"))
2574}

◆ ParseCommand()

AX_BASE_EXPORT ax::mojom::Command ui::ParseCommand ( const char *  command)

Definition at line 2138 of file ax_enum_util.cc.

2138 {
2139 if (0 == strcmp(command, "clearSelection"))
2141 if (0 == strcmp(command, "cut"))
2143 if (0 == strcmp(command, "delete"))
2145 if (0 == strcmp(command, "dictate"))
2147 if (0 == strcmp(command, "extendSelection"))
2149 if (0 == strcmp(command, "format"))
2151 if (0 == strcmp(command, "insert"))
2153 if (0 == strcmp(command, "marker"))
2155 if (0 == strcmp(command, "moveSelection"))
2157 if (0 == strcmp(command, "paste"))
2159 if (0 == strcmp(command, "replace"))
2161 if (0 == strcmp(command, "setSelection"))
2163 if (0 == strcmp(command, "type"))
2165
2166 // Return the default command.
2168}
list command
Definition: valgrind.py:24

◆ ParseDefaultActionVerb()

AX_BASE_EXPORT ax::mojom::DefaultActionVerb ui::ParseDefaultActionVerb ( const char *  default_action_verb)

Definition at line 1350 of file ax_enum_util.cc.

1351 {
1352 if (0 == strcmp(default_action_verb, "none"))
1354 if (0 == strcmp(default_action_verb, "activate"))
1356 if (0 == strcmp(default_action_verb, "check"))
1358 if (0 == strcmp(default_action_verb, "click"))
1360 // Some screen readers, such as Jaws, expect the following spelling of this
1361 // verb.
1362 if (0 == strcmp(default_action_verb, "click-ancestor"))
1364 if (0 == strcmp(default_action_verb, "jump"))
1366 if (0 == strcmp(default_action_verb, "open"))
1368 if (0 == strcmp(default_action_verb, "press"))
1370 if (0 == strcmp(default_action_verb, "select"))
1372 if (0 == strcmp(default_action_verb, "uncheck"))
1375}

◆ ParseDescriptionFrom()

AX_BASE_EXPORT ax::mojom::DescriptionFrom ui::ParseDescriptionFrom ( const char *  description_from)

Definition at line 2677 of file ax_enum_util.cc.

2677 {
2678 if (0 == strcmp(description_from, "none"))
2680 if (0 == strcmp(description_from, "uninitialized"))
2682 if (0 == strcmp(description_from, "attribute"))
2684 if (0 == strcmp(description_from, "contents"))
2686 if (0 == strcmp(description_from, "relatedElement"))
2688 if (0 == strcmp(description_from, "title"))
2691}

◆ ParseDropeffect()

AX_BASE_EXPORT ax::mojom::Dropeffect ui::ParseDropeffect ( const char *  dropeffect)

Definition at line 2945 of file ax_enum_util.cc.

2945 {
2946 if (0 == strcmp(dropeffect, "copy"))
2948 if (0 == strcmp(dropeffect, "execute"))
2950 if (0 == strcmp(dropeffect, "link"))
2952 if (0 == strcmp(dropeffect, "move"))
2954 if (0 == strcmp(dropeffect, "popup"))
2957}

◆ ParseEvent()

AX_BASE_EXPORT ax::mojom::Event ui::ParseEvent ( const char *  event)

Definition at line 138 of file ax_enum_util.cc.

138 {
139 if (0 == strcmp(event, "none"))
141 if (0 == strcmp(event, "activedescendantchanged"))
143 if (0 == strcmp(event, "alert"))
145 if (0 == strcmp(event, "ariaAttributeChanged"))
147 if (0 == strcmp(event, "autocorrectionOccured"))
149 if (0 == strcmp(event, "blur"))
151 if (0 == strcmp(event, "checkedStateChanged"))
153 if (0 == strcmp(event, "childrenChanged"))
155 if (0 == strcmp(event, "clicked"))
157 if (0 == strcmp(event, "controlsChanged"))
159 if (0 == strcmp(event, "documentSelectionChanged"))
161 if (0 == strcmp(event, "documentTitleChanged"))
163 if (0 == strcmp(event, "endOfTest"))
165 if (0 == strcmp(event, "expandedChanged"))
167 if (0 == strcmp(event, "focus"))
169 if (0 == strcmp(event, "focusAfterMenuClose"))
171 if (0 == strcmp(event, "focusContext"))
173 if (0 == strcmp(event, "hide"))
175 if (0 == strcmp(event, "hitTestResult"))
177 if (0 == strcmp(event, "hover"))
179 if (0 == strcmp(event, "imageFrameUpdated"))
181 if (0 == strcmp(event, "invalidStatusChanged"))
183 if (0 == strcmp(event, "layoutComplete"))
185 if (0 == strcmp(event, "liveRegionCreated"))
187 if (0 == strcmp(event, "liveRegionChanged"))
189 if (0 == strcmp(event, "loadComplete"))
191 if (0 == strcmp(event, "loadStart"))
193 if (0 == strcmp(event, "locationChanged"))
195 if (0 == strcmp(event, "mediaStartedPlaying"))
197 if (0 == strcmp(event, "mediaStoppedPlaying"))
199 if (0 == strcmp(event, "menuEnd"))
201 if (0 == strcmp(event, "menuListItemSelected"))
203 if (0 == strcmp(event, "menuListValueChanged"))
205 if (0 == strcmp(event, "menuPopupEnd"))
207 if (0 == strcmp(event, "menuPopupStart"))
209 if (0 == strcmp(event, "menuStart"))
211 if (0 == strcmp(event, "mouseCanceled"))
213 if (0 == strcmp(event, "mouseDragged"))
215 if (0 == strcmp(event, "mouseMoved"))
217 if (0 == strcmp(event, "mousePressed"))
219 if (0 == strcmp(event, "mouseReleased"))
221 if (0 == strcmp(event, "rowCollapsed"))
223 if (0 == strcmp(event, "rowCountChanged"))
225 if (0 == strcmp(event, "rowExpanded"))
227 if (0 == strcmp(event, "scrollPositionChanged"))
229 if (0 == strcmp(event, "scrolledToAnchor"))
231 if (0 == strcmp(event, "selectedChildrenChanged"))
233 if (0 == strcmp(event, "selection"))
235 if (0 == strcmp(event, "selectionAdd"))
237 if (0 == strcmp(event, "selectionRemove"))
239 if (0 == strcmp(event, "show"))
241 if (0 == strcmp(event, "stateChanged"))
243 if (0 == strcmp(event, "textChanged"))
245 if (0 == strcmp(event, "textSelectionChanged"))
247 if (0 == strcmp(event, "tooltipClosed"))
249 if (0 == strcmp(event, "tooltipOpened"))
251 if (0 == strcmp(event, "windowActivated"))
253 if (0 == strcmp(event, "windowDeactivated"))
255 if (0 == strcmp(event, "windowVisibilityChanged"))
257 if (0 == strcmp(event, "treeChanged"))
259 if (0 == strcmp(event, "valueChanged"))
262}

◆ ParseEventFrom()

AX_BASE_EXPORT ax::mojom::EventFrom ui::ParseEventFrom ( const char *  event_from)

Definition at line 2708 of file ax_enum_util.cc.

2708 {
2709 if (0 == strcmp(event_from, "none"))
2711 if (0 == strcmp(event_from, "user"))
2713 if (0 == strcmp(event_from, "page"))
2715 if (0 == strcmp(event_from, "action"))
2718}

◆ ParseFloatAttribute()

AX_BASE_EXPORT ax::mojom::FloatAttribute ui::ParseFloatAttribute ( const char *  float_attribute)

Definition at line 1805 of file ax_enum_util.cc.

1805 {
1806 if (0 == strcmp(float_attribute, "none"))
1808 if (0 == strcmp(float_attribute, "valueForRange"))
1810 if (0 == strcmp(float_attribute, "minValueForRange"))
1812 if (0 == strcmp(float_attribute, "maxValueForRange"))
1814 if (0 == strcmp(float_attribute, "stepValueForRange"))
1816 if (0 == strcmp(float_attribute, "fontSize"))
1818 if (0 == strcmp(float_attribute, "fontWeight"))
1820 if (0 == strcmp(float_attribute, "textIndent"))
1823}

◆ ParseGesture()

AX_BASE_EXPORT ax::mojom::Gesture ui::ParseGesture ( const char *  gesture)

Definition at line 2771 of file ax_enum_util.cc.

2771 {
2772 if (0 == strcmp(gesture, "none"))
2774 if (0 == strcmp(gesture, "click"))
2776 if (0 == strcmp(gesture, "swipeLeft1"))
2778 if (0 == strcmp(gesture, "swipeUp1"))
2780 if (0 == strcmp(gesture, "swipeRight1"))
2782 if (0 == strcmp(gesture, "swipeDown1"))
2784 if (0 == strcmp(gesture, "swipeLeft2"))
2786 if (0 == strcmp(gesture, "swipeUp2"))
2788 if (0 == strcmp(gesture, "swipeRight2"))
2790 if (0 == strcmp(gesture, "swipeDown2"))
2792 if (0 == strcmp(gesture, "swipeLeft3"))
2794 if (0 == strcmp(gesture, "swipeUp3"))
2796 if (0 == strcmp(gesture, "swipeRight3"))
2798 if (0 == strcmp(gesture, "swipeDown3"))
2800 if (0 == strcmp(gesture, "swipeLeft4"))
2802 if (0 == strcmp(gesture, "swipeUp4"))
2804 if (0 == strcmp(gesture, "swipeRight4"))
2806 if (0 == strcmp(gesture, "swipeDown4"))
2808 if (0 == strcmp(gesture, "tap2"))
2810 if (0 == strcmp(gesture, "tap3"))
2812 if (0 == strcmp(gesture, "tap4"))
2814 if (0 == strcmp(gesture, "touchExplore"))
2817}

◆ ParseHasPopup()

AX_BASE_EXPORT ax::mojom::HasPopup ui::ParseHasPopup ( const char *  has_popup)

Definition at line 2482 of file ax_enum_util.cc.

2482 {
2483 if (0 == strcmp(has_popup, "true"))
2485 if (0 == strcmp(has_popup, "menu"))
2487 if (0 == strcmp(has_popup, "listbox"))
2489 if (0 == strcmp(has_popup, "tree"))
2491 if (0 == strcmp(has_popup, "grid"))
2493 if (0 == strcmp(has_popup, "dialog"))
2495
2497}

◆ ParseImageAnnotationStatus()

AX_BASE_EXPORT ax::mojom::ImageAnnotationStatus ui::ParseImageAnnotationStatus ( const char *  status)

Definition at line 2900 of file ax_enum_util.cc.

2901 {
2902 if (0 == strcmp(status, "none"))
2904 if (0 == strcmp(status, "kWillNotAnnotateDueToScheme"))
2906 if (0 == strcmp(status, "ineligibleForAnnotation"))
2908 if (0 == strcmp(status, "eligibleForAnnotation"))
2910 if (0 == strcmp(status, "silentlyEligibleForAnnotation"))
2912 if (0 == strcmp(status, "annotationPending"))
2914 if (0 == strcmp(status, "annotationSucceeded"))
2916 if (0 == strcmp(status, "annotationEmpty"))
2918 if (0 == strcmp(status, "annotationAdult"))
2920 if (0 == strcmp(status, "annotationProcessFailed"))
2922
2924}

◆ ParseIntAttribute()

AX_BASE_EXPORT ax::mojom::IntAttribute ui::ParseIntAttribute ( const char *  int_attribute)

Definition at line 1656 of file ax_enum_util.cc.

1656 {
1657 if (0 == strcmp(int_attribute, "none"))
1659 if (0 == strcmp(int_attribute, "defaultActionVerb"))
1661 if (0 == strcmp(int_attribute, "dropeffect"))
1663 if (0 == strcmp(int_attribute, "scrollX"))
1665 if (0 == strcmp(int_attribute, "scrollXMin"))
1667 if (0 == strcmp(int_attribute, "scrollXMax"))
1669 if (0 == strcmp(int_attribute, "scrollY"))
1671 if (0 == strcmp(int_attribute, "scrollYMin"))
1673 if (0 == strcmp(int_attribute, "scrollYMax"))
1675 if (0 == strcmp(int_attribute, "textSelStart"))
1677 if (0 == strcmp(int_attribute, "textSelEnd"))
1679 if (0 == strcmp(int_attribute, "ariaColumnCount"))
1681 if (0 == strcmp(int_attribute, "ariaCellColumnIndex"))
1683 if (0 == strcmp(int_attribute, "ariaCellColumnSpan"))
1685 if (0 == strcmp(int_attribute, "ariaRowCount"))
1687 if (0 == strcmp(int_attribute, "ariaCellRowIndex"))
1689 if (0 == strcmp(int_attribute, "ariaCellRowSpan"))
1691 if (0 == strcmp(int_attribute, "tableRowCount"))
1693 if (0 == strcmp(int_attribute, "tableColumnCount"))
1695 if (0 == strcmp(int_attribute, "tableHeaderId"))
1697 if (0 == strcmp(int_attribute, "tableRowIndex"))
1699 if (0 == strcmp(int_attribute, "tableRowHeaderId"))
1701 if (0 == strcmp(int_attribute, "tableColumnIndex"))
1703 if (0 == strcmp(int_attribute, "tableColumnHeaderId"))
1705 if (0 == strcmp(int_attribute, "tableCellColumnIndex"))
1707 if (0 == strcmp(int_attribute, "tableCellColumnSpan"))
1709 if (0 == strcmp(int_attribute, "tableCellRowIndex"))
1711 if (0 == strcmp(int_attribute, "tableCellRowSpan"))
1713 if (0 == strcmp(int_attribute, "sortDirection"))
1715 if (0 == strcmp(int_attribute, "hierarchicalLevel"))
1717 if (0 == strcmp(int_attribute, "nameFrom"))
1719 if (0 == strcmp(int_attribute, "descriptionFrom"))
1721 if (0 == strcmp(int_attribute, "activedescendantId"))
1723 if (0 == strcmp(int_attribute, "errormessageId"))
1725 if (0 == strcmp(int_attribute, "inPageLinkTargetId"))
1727 if (0 == strcmp(int_attribute, "memberOfId"))
1729 if (0 == strcmp(int_attribute, "nextOnLineId"))
1731 if (0 == strcmp(int_attribute, "popupForId"))
1733 if (0 == strcmp(int_attribute, "previousOnLineId"))
1735 if (0 == strcmp(int_attribute, "restriction"))
1737 if (0 == strcmp(int_attribute, "setSize"))
1739 if (0 == strcmp(int_attribute, "posInSet"))
1741 if (0 == strcmp(int_attribute, "colorValue"))
1743 if (0 == strcmp(int_attribute, "ariaCurrentState"))
1745 if (0 == strcmp(int_attribute, "backgroundColor"))
1747 if (0 == strcmp(int_attribute, "color"))
1749 if (0 == strcmp(int_attribute, "haspopup"))
1751 if (0 == strcmp(int_attribute, "invalidState"))
1753 if (0 == strcmp(int_attribute, "checkedState"))
1755 if (0 == strcmp(int_attribute, "listStyle"))
1757 if (0 == strcmp(int_attribute, "text-align"))
1759 if (0 == strcmp(int_attribute, "textDirection"))
1761 if (0 == strcmp(int_attribute, "textPosition"))
1763 if (0 == strcmp(int_attribute, "textStyle"))
1765 if (0 == strcmp(int_attribute, "textOverlineStyle"))
1767 if (0 == strcmp(int_attribute, "textStrikethroughStyle"))
1769 if (0 == strcmp(int_attribute, "textUnderlineStyle"))
1771 if (0 == strcmp(int_attribute, "previousFocusId"))
1773 if (0 == strcmp(int_attribute, "nextFocusId"))
1775 if (0 == strcmp(int_attribute, "imageAnnotationStatus"))
1777 if (0 == strcmp(int_attribute, "domNodeId"))
1780}

◆ ParseIntListAttribute()

AX_BASE_EXPORT ax::mojom::IntListAttribute ui::ParseIntListAttribute ( const char *  int_list_attribute)

Definition at line 1955 of file ax_enum_util.cc.

1956 {
1957 if (0 == strcmp(int_list_attribute, "none"))
1959 if (0 == strcmp(int_list_attribute, "indirectChildIds"))
1961 if (0 == strcmp(int_list_attribute, "controlsIds"))
1963 if (0 == strcmp(int_list_attribute, "detailsIds"))
1965 if (0 == strcmp(int_list_attribute, "describedbyIds"))
1967 if (0 == strcmp(int_list_attribute, "flowtoIds"))
1969 if (0 == strcmp(int_list_attribute, "labelledbyIds"))
1971 if (0 == strcmp(int_list_attribute, "radioGroupIds"))
1973 if (0 == strcmp(int_list_attribute, "markerTypes"))
1975 if (0 == strcmp(int_list_attribute, "markerStarts"))
1977 if (0 == strcmp(int_list_attribute, "markerEnds"))
1979 if (0 == strcmp(int_list_attribute, "characterOffsets"))
1981 if (0 == strcmp(int_list_attribute, "cachedLineStarts"))
1983 if (0 == strcmp(int_list_attribute, "wordStarts"))
1985 if (0 == strcmp(int_list_attribute, "wordEnds"))
1987 if (0 == strcmp(int_list_attribute, "customActionIds"))
1990}

◆ ParseInvalidState()

AX_BASE_EXPORT ax::mojom::InvalidState ui::ParseInvalidState ( const char *  invalid_state)

Definition at line 2514 of file ax_enum_util.cc.

2514 {
2515 if (0 == strcmp(invalid_state, "none"))
2517 if (0 == strcmp(invalid_state, "false"))
2519 if (0 == strcmp(invalid_state, "true"))
2521 if (0 == strcmp(invalid_state, "other"))
2524}

◆ ParseListStyle()

AX_BASE_EXPORT ax::mojom::ListStyle ui::ParseListStyle ( const char *  list_style)

Definition at line 2033 of file ax_enum_util.cc.

2033 {
2034 if (0 == strcmp(list_style, "none"))
2036 if (0 == strcmp(list_style, "circle"))
2038 if (0 == strcmp(list_style, "disc"))
2040 if (0 == strcmp(list_style, "image"))
2042 if (0 == strcmp(list_style, "numeric"))
2044 if (0 == strcmp(list_style, "other"))
2046 if (0 == strcmp(list_style, "square"))
2049}

◆ ParseMarkerType()

AX_BASE_EXPORT ax::mojom::MarkerType ui::ParseMarkerType ( const char *  marker_type)

Definition at line 2070 of file ax_enum_util.cc.

2070 {
2071 if (0 == strcmp(marker_type, "none"))
2073 if (0 == strcmp(marker_type, "spelling"))
2075 if (0 == strcmp(marker_type, "grammar"))
2077 if (0 == strcmp(marker_type, "textMatch"))
2079 if (0 == strcmp(marker_type, "activeSuggestion"))
2081 if (0 == strcmp(marker_type, "suggestion"))
2084}

◆ ParseMoveDirection()

AX_BASE_EXPORT ax::mojom::MoveDirection ui::ParseMoveDirection ( const char *  move_direction)

Definition at line 2097 of file ax_enum_util.cc.

2097 {
2098 if (0 == strcmp(move_direction, "forward"))
2100 if (0 == strcmp(move_direction, "backward"))
2103}

◆ ParseMutation()

AX_BASE_EXPORT ax::mojom::Mutation ui::ParseMutation ( const char *  mutation)

Definition at line 1394 of file ax_enum_util.cc.

1394 {
1395 if (0 == strcmp(mutation, "none"))
1397 if (0 == strcmp(mutation, "nodeCreated"))
1399 if (0 == strcmp(mutation, "subtreeCreated"))
1401 if (0 == strcmp(mutation, "nodeChanged"))
1403 if (0 == strcmp(mutation, "nodeRemoved"))
1406}

◆ ParseNameFrom()

AX_BASE_EXPORT ax::mojom::NameFrom ui::ParseNameFrom ( const char *  name_from)

Definition at line 2634 of file ax_enum_util.cc.

2634 {
2635 if (0 == strcmp(name_from, "none"))
2637 if (0 == strcmp(name_from, "uninitialized"))
2639 if (0 == strcmp(name_from, "attribute"))
2641 if (0 == strcmp(name_from, "attributeExplicitlyEmpty"))
2643 if (0 == strcmp(name_from, "caption"))
2645 if (0 == strcmp(name_from, "contents"))
2647 if (0 == strcmp(name_from, "placeholder"))
2649 if (0 == strcmp(name_from, "relatedElement"))
2651 if (0 == strcmp(name_from, "title"))
2653 if (0 == strcmp(name_from, "value"))
2656}

◆ ParseRestriction()

AX_BASE_EXPORT ax::mojom::Restriction ui::ParseRestriction ( const char *  restriction)

Definition at line 2539 of file ax_enum_util.cc.

2539 {
2540 if (0 == strcmp(restriction, "none"))
2542 if (0 == strcmp(restriction, "readOnly"))
2544 if (0 == strcmp(restriction, "disabled"))
2547}

◆ ParseRole()

AX_BASE_EXPORT ax::mojom::Role ui::ParseRole ( const char *  role)

Definition at line 647 of file ax_enum_util.cc.

647 {
648 if (0 == strcmp(role, "none"))
650 if (0 == strcmp(role, "abbr"))
652 if (0 == strcmp(role, "alertDialog"))
654 if (0 == strcmp(role, "alert"))
656 if (0 == strcmp(role, "anchor"))
658 if (0 == strcmp(role, "application"))
660 if (0 == strcmp(role, "article"))
662 if (0 == strcmp(role, "audio"))
664 if (0 == strcmp(role, "banner"))
666 if (0 == strcmp(role, "blockquote"))
668 if (0 == strcmp(role, "button"))
670 if (0 == strcmp(role, "canvas"))
672 if (0 == strcmp(role, "caption"))
674 if (0 == strcmp(role, "caret"))
676 if (0 == strcmp(role, "cell"))
678 if (0 == strcmp(role, "checkBox"))
680 if (0 == strcmp(role, "client"))
682 if (0 == strcmp(role, "code"))
684 if (0 == strcmp(role, "colorWell"))
686 if (0 == strcmp(role, "columnHeader"))
688 if (0 == strcmp(role, "column"))
690 if (0 == strcmp(role, "comboBoxGrouping"))
692 if (0 == strcmp(role, "comboBoxMenuButton"))
694 if (0 == strcmp(role, "comment"))
696 if (0 == strcmp(role, "complementary"))
698 if (0 == strcmp(role, "contentDeletion"))
700 if (0 == strcmp(role, "contentInsertion"))
702 if (0 == strcmp(role, "contentInfo"))
704 if (0 == strcmp(role, "date"))
706 if (0 == strcmp(role, "dateTime"))
708 if (0 == strcmp(role, "definition"))
710 if (0 == strcmp(role, "descriptionListDetail"))
712 if (0 == strcmp(role, "descriptionList"))
714 if (0 == strcmp(role, "descriptionListTerm"))
716 if (0 == strcmp(role, "desktop"))
718 if (0 == strcmp(role, "details"))
720 if (0 == strcmp(role, "dialog"))
722 if (0 == strcmp(role, "directory"))
724 if (0 == strcmp(role, "disclosureTriangle"))
726 if (0 == strcmp(role, "docAbstract"))
728 if (0 == strcmp(role, "docAcknowledgments"))
730 if (0 == strcmp(role, "docAfterword"))
732 if (0 == strcmp(role, "docAppendix"))
734 if (0 == strcmp(role, "docBackLink"))
736 if (0 == strcmp(role, "docBiblioEntry"))
738 if (0 == strcmp(role, "docBibliography"))
740 if (0 == strcmp(role, "docBiblioRef"))
742 if (0 == strcmp(role, "docChapter"))
744 if (0 == strcmp(role, "docColophon"))
746 if (0 == strcmp(role, "docConclusion"))
748 if (0 == strcmp(role, "docCover"))
750 if (0 == strcmp(role, "docCredit"))
752 if (0 == strcmp(role, "docCredits"))
754 if (0 == strcmp(role, "docDedication"))
756 if (0 == strcmp(role, "docEndnote"))
758 if (0 == strcmp(role, "docEndnotes"))
760 if (0 == strcmp(role, "docEpigraph"))
762 if (0 == strcmp(role, "docEpilogue"))
764 if (0 == strcmp(role, "docErrata"))
766 if (0 == strcmp(role, "docExample"))
768 if (0 == strcmp(role, "docFootnote"))
770 if (0 == strcmp(role, "docForeword"))
772 if (0 == strcmp(role, "docGlossary"))
774 if (0 == strcmp(role, "docGlossref"))
776 if (0 == strcmp(role, "docIndex"))
778 if (0 == strcmp(role, "docIntroduction"))
780 if (0 == strcmp(role, "docNoteRef"))
782 if (0 == strcmp(role, "docNotice"))
784 if (0 == strcmp(role, "docPageBreak"))
786 if (0 == strcmp(role, "docPageList"))
788 if (0 == strcmp(role, "docPart"))
790 if (0 == strcmp(role, "docPreface"))
792 if (0 == strcmp(role, "docPrologue"))
794 if (0 == strcmp(role, "docPullquote"))
796 if (0 == strcmp(role, "docQna"))
798 if (0 == strcmp(role, "docSubtitle"))
800 if (0 == strcmp(role, "docTip"))
802 if (0 == strcmp(role, "docToc"))
804 if (0 == strcmp(role, "document"))
806 if (0 == strcmp(role, "embeddedObject"))
808 if (0 == strcmp(role, "emphasis"))
810 if (0 == strcmp(role, "feed"))
812 if (0 == strcmp(role, "figcaption"))
814 if (0 == strcmp(role, "figure"))
816 if (0 == strcmp(role, "footer"))
818 if (0 == strcmp(role, "footerAsNonLandmark"))
820 if (0 == strcmp(role, "form"))
822 if (0 == strcmp(role, "genericContainer"))
824 if (0 == strcmp(role, "graphicsDocument"))
826 if (0 == strcmp(role, "graphicsObject"))
828 if (0 == strcmp(role, "graphicsSymbol"))
830 if (0 == strcmp(role, "grid"))
832 if (0 == strcmp(role, "group"))
834 if (0 == strcmp(role, "heading"))
836 if (0 == strcmp(role, "header"))
838 if (0 == strcmp(role, "headerAsNonLandmark"))
840 if (0 == strcmp(role, "pdfActionableHighlight"))
842 if (0 == strcmp(role, "iframe"))
844 if (0 == strcmp(role, "iframePresentational"))
846 if (0 == strcmp(role, "ignored"))
848 if (0 == strcmp(role, "imageMap"))
850 if (0 == strcmp(role, "image"))
852 if (0 == strcmp(role, "imeCandidate"))
854 if (0 == strcmp(role, "inlineTextBox"))
856 if (0 == strcmp(role, "inputTime"))
858 if (0 == strcmp(role, "keyboard"))
860 if (0 == strcmp(role, "labelText"))
862 if (0 == strcmp(role, "layoutTable"))
864 if (0 == strcmp(role, "layoutTableCell"))
866 if (0 == strcmp(role, "layoutTableRow"))
868 if (0 == strcmp(role, "legend"))
870 if (0 == strcmp(role, "lineBreak"))
872 if (0 == strcmp(role, "link"))
874 if (0 == strcmp(role, "listBoxOption"))
876 if (0 == strcmp(role, "listBox"))
878 if (0 == strcmp(role, "listGrid"))
880 if (0 == strcmp(role, "listItem"))
882 if (0 == strcmp(role, "listMarker"))
884 if (0 == strcmp(role, "list"))
886 if (0 == strcmp(role, "log"))
888 if (0 == strcmp(role, "main"))
890 if (0 == strcmp(role, "mark"))
892 if (0 == strcmp(role, "marquee"))
894 if (0 == strcmp(role, "math"))
896 if (0 == strcmp(role, "menu"))
898 if (0 == strcmp(role, "menuBar"))
900 if (0 == strcmp(role, "menuItem"))
902 if (0 == strcmp(role, "menuItemCheckBox"))
904 if (0 == strcmp(role, "menuItemRadio"))
906 if (0 == strcmp(role, "menuListOption"))
908 if (0 == strcmp(role, "menuListPopup"))
910 if (0 == strcmp(role, "meter"))
912 if (0 == strcmp(role, "navigation"))
914 if (0 == strcmp(role, "note"))
916 if (0 == strcmp(role, "pane"))
918 if (0 == strcmp(role, "paragraph"))
920 if (0 == strcmp(role, "pluginObject"))
922 if (0 == strcmp(role, "popUpButton"))
924 if (0 == strcmp(role, "portal"))
926 if (0 == strcmp(role, "pre"))
928 if (0 == strcmp(role, "presentational"))
930 if (0 == strcmp(role, "progressIndicator"))
932 if (0 == strcmp(role, "radioButton"))
934 if (0 == strcmp(role, "radioGroup"))
936 if (0 == strcmp(role, "region"))
938 if (0 == strcmp(role, "rootWebArea"))
940 if (0 == strcmp(role, "row"))
942 if (0 == strcmp(role, "rowGroup"))
944 if (0 == strcmp(role, "rowHeader"))
946 if (0 == strcmp(role, "ruby"))
948 if (0 == strcmp(role, "rubyAnnotation"))
950 if (0 == strcmp(role, "section"))
952 if (0 == strcmp(role, "scrollBar"))
954 if (0 == strcmp(role, "scrollView"))
956 if (0 == strcmp(role, "search"))
958 if (0 == strcmp(role, "searchBox"))
960 if (0 == strcmp(role, "slider"))
962 if (0 == strcmp(role, "sliderThumb"))
964 if (0 == strcmp(role, "spinButton"))
966 if (0 == strcmp(role, "splitter"))
968 if (0 == strcmp(role, "staticText"))
970 if (0 == strcmp(role, "status"))
972 if (0 == strcmp(role, "suggestion"))
974 if (0 == strcmp(role, "svgRoot"))
976 if (0 == strcmp(role, "switch"))
978 if (0 == strcmp(role, "strong"))
980 if (0 == strcmp(role, "tabList"))
982 if (0 == strcmp(role, "tabPanel"))
984 if (0 == strcmp(role, "tab"))
986 if (0 == strcmp(role, "tableHeaderContainer"))
988 if (0 == strcmp(role, "table"))
990 if (0 == strcmp(role, "term"))
992 if (0 == strcmp(role, "textField"))
994 if (0 == strcmp(role, "textFieldWithComboBox"))
996 if (0 == strcmp(role, "time"))
998 if (0 == strcmp(role, "timer"))
1000 if (0 == strcmp(role, "titleBar"))
1002 if (0 == strcmp(role, "toggleButton"))
1004 if (0 == strcmp(role, "toolbar"))
1006 if (0 == strcmp(role, "treeGrid"))
1008 if (0 == strcmp(role, "treeItem"))
1010 if (0 == strcmp(role, "tree"))
1012 if (0 == strcmp(role, "unknown"))
1014 if (0 == strcmp(role, "tooltip"))
1016 if (0 == strcmp(role, "video"))
1018 if (0 == strcmp(role, "webArea"))
1020 if (0 == strcmp(role, "webView"))
1022 if (0 == strcmp(role, "window"))
1025}

◆ ParseScrollAlignment()

ax::mojom::ScrollAlignment ui::ParseScrollAlignment ( const char *  scroll_alignment)

Definition at line 1303 of file ax_enum_util.cc.

1303 {
1304 if (0 == strcmp(scroll_alignment, "none"))
1306 if (0 == strcmp(scroll_alignment, "scrollAlignmentCenter"))
1308 if (0 == strcmp(scroll_alignment, "scrollAlignmentTop"))
1310 if (0 == strcmp(scroll_alignment, "scrollAlignmentBottom"))
1312 if (0 == strcmp(scroll_alignment, "scrollAlignmentLeft"))
1314 if (0 == strcmp(scroll_alignment, "scrollAlignmentRight"))
1316 if (0 == strcmp(scroll_alignment, "scrollAlignmentClosestEdge"))
1319}

◆ ParseSortDirection()

AX_BASE_EXPORT ax::mojom::SortDirection ui::ParseSortDirection ( const char *  sort_direction)

Definition at line 2593 of file ax_enum_util.cc.

2593 {
2594 if (0 == strcmp(sort_direction, "none"))
2596 if (0 == strcmp(sort_direction, "unsorted"))
2598 if (0 == strcmp(sort_direction, "ascending"))
2600 if (0 == strcmp(sort_direction, "descending"))
2602 if (0 == strcmp(sort_direction, "other"))
2605}

◆ ParseState()

AX_BASE_EXPORT ax::mojom::State ui::ParseState ( const char *  state)

Definition at line 1072 of file ax_enum_util.cc.

1072 {
1073 if (0 == strcmp(state, "none"))
1075 if (0 == strcmp(state, "autofillAvailable"))
1077 if (0 == strcmp(state, "collapsed"))
1079 if (0 == strcmp(state, "default"))
1081 if (0 == strcmp(state, "editable"))
1083 if (0 == strcmp(state, "expanded"))
1085 if (0 == strcmp(state, "focusable"))
1087 if (0 == strcmp(state, "horizontal"))
1089 if (0 == strcmp(state, "hovered"))
1091 if (0 == strcmp(state, "ignored"))
1093 if (0 == strcmp(state, "invisible"))
1095 if (0 == strcmp(state, "linked"))
1097 if (0 == strcmp(state, "multiline"))
1099 if (0 == strcmp(state, "multiselectable"))
1101 if (0 == strcmp(state, "protected"))
1103 if (0 == strcmp(state, "required"))
1105 if (0 == strcmp(state, "richlyEditable"))
1107 if (0 == strcmp(state, "vertical"))
1109 if (0 == strcmp(state, "visited"))
1112}
AtkStateType state

◆ ParseStringAttribute()

AX_BASE_EXPORT ax::mojom::StringAttribute ui::ParseStringAttribute ( const char *  string_attribute)

Definition at line 1469 of file ax_enum_util.cc.

1469 {
1470 if (0 == strcmp(string_attribute, "none"))
1472 if (0 == strcmp(string_attribute, "accessKey"))
1474 if (0 == strcmp(string_attribute, "ariaInvalidValue"))
1476 if (0 == strcmp(string_attribute, "autoComplete"))
1478 if (0 == strcmp(string_attribute, "childTreeId"))
1480 if (0 == strcmp(string_attribute, "className"))
1482 if (0 == strcmp(string_attribute, "containerLiveRelevant"))
1484 if (0 == strcmp(string_attribute, "containerLiveStatus"))
1486 if (0 == strcmp(string_attribute, "description"))
1488 if (0 == strcmp(string_attribute, "display"))
1490 if (0 == strcmp(string_attribute, "fontFamily"))
1492 if (0 == strcmp(string_attribute, "htmlTag"))
1494 if (0 == strcmp(string_attribute, "imageAnnotation"))
1496 if (0 == strcmp(string_attribute, "imageDataUrl"))
1498 if (0 == strcmp(string_attribute, "innerHtml"))
1500 if (0 == strcmp(string_attribute, "inputType"))
1502 if (0 == strcmp(string_attribute, "keyShortcuts"))
1504 if (0 == strcmp(string_attribute, "language"))
1506 if (0 == strcmp(string_attribute, "name"))
1508 if (0 == strcmp(string_attribute, "liveRelevant"))
1510 if (0 == strcmp(string_attribute, "liveStatus"))
1512 if (0 == strcmp(string_attribute, "placeholder"))
1514 if (0 == strcmp(string_attribute, "role"))
1516 if (0 == strcmp(string_attribute, "roleDescription"))
1518 if (0 == strcmp(string_attribute, "tooltip"))
1520 if (0 == strcmp(string_attribute, "url"))
1522 if (0 == strcmp(string_attribute, "value"))
1525}

◆ ParseStringListAttribute()

AX_BASE_EXPORT ax::mojom::StringListAttribute ui::ParseStringListAttribute ( const char *  string_list_attribute)

Definition at line 2003 of file ax_enum_util.cc.

2004 {
2005 if (0 == strcmp(string_list_attribute, "none"))
2007 if (0 == strcmp(string_list_attribute, "customActionDescriptions"))
2010}

◆ ParseTextAffinity()

AX_BASE_EXPORT ax::mojom::TextAffinity ui::ParseTextAffinity ( const char *  text_affinity)

Definition at line 2832 of file ax_enum_util.cc.

2832 {
2833 if (0 == strcmp(text_affinity, "none"))
2835 if (0 == strcmp(text_affinity, "downstream"))
2837 if (0 == strcmp(text_affinity, "upstream"))
2840}

◆ ParseTextAlign()

AX_BASE_EXPORT ax::mojom::TextAlign ui::ParseTextAlign ( const char *  text_align)

Definition at line 2310 of file ax_enum_util.cc.

2310 {
2311 if (0 == strcmp(text_align, "none"))
2313 if (0 == strcmp(text_align, "left"))
2315 if (0 == strcmp(text_align, "right"))
2317 if (0 == strcmp(text_align, "center"))
2319 if (0 == strcmp(text_align, "justify"))
2322}

◆ ParseTextBoundary()

AX_BASE_EXPORT ax::mojom::TextBoundary ui::ParseTextBoundary ( const char *  text_boundary)

Definition at line 2215 of file ax_enum_util.cc.

2215 {
2216 if (0 == strcmp(text_boundary, "object"))
2218 if (0 == strcmp(text_boundary, "character"))
2220 if (0 == strcmp(text_boundary, "format"))
2222 if (0 == strcmp(text_boundary, "lineEnd"))
2224 if (0 == strcmp(text_boundary, "lineStart"))
2226 if (0 == strcmp(text_boundary, "lineStartOrEnd"))
2228 if (0 == strcmp(text_boundary, "pageEnd"))
2230 if (0 == strcmp(text_boundary, "pageStart"))
2232 if (0 == strcmp(text_boundary, "pageStartOrEnd"))
2234 if (0 == strcmp(text_boundary, "paragraphEnd"))
2236 if (0 == strcmp(text_boundary, "paragraphStart"))
2238 if (0 == strcmp(text_boundary, "paragraphStartOrEnd"))
2240 if (0 == strcmp(text_boundary, "sentenceEnd"))
2242 if (0 == strcmp(text_boundary, "sentenceStart"))
2244 if (0 == strcmp(text_boundary, "sentenceStartOrEnd"))
2246 if (0 == strcmp(text_boundary, "webPage"))
2248 if (0 == strcmp(text_boundary, "wordEnd"))
2250 if (0 == strcmp(text_boundary, "wordStart"))
2252 if (0 == strcmp(text_boundary, "wordStartOrEnd"))
2255}

◆ ParseTextDecorationStyle()

AX_BASE_EXPORT ax::mojom::TextDecorationStyle ui::ParseTextDecorationStyle ( const char *  text_decoration_style)

Definition at line 2276 of file ax_enum_util.cc.

2277 {
2278 if (0 == strcmp(text_decoration_style, "none"))
2280 if (0 == strcmp(text_decoration_style, "solid"))
2282 if (0 == strcmp(text_decoration_style, "dashed"))
2284 if (0 == strcmp(text_decoration_style, "dotted"))
2286 if (0 == strcmp(text_decoration_style, "double"))
2288 if (0 == strcmp(text_decoration_style, "wavy"))
2291}

◆ ParseTextDirection()

AX_BASE_EXPORT ax::mojom::WritingDirection ui::ParseTextDirection ( const char *  text_direction)

Definition at line 2341 of file ax_enum_util.cc.

2341 {
2342 if (0 == strcmp(text_direction, "none"))
2344 if (0 == strcmp(text_direction, "ltr"))
2346 if (0 == strcmp(text_direction, "rtl"))
2348 if (0 == strcmp(text_direction, "ttb"))
2350 if (0 == strcmp(text_direction, "btt"))
2353}

◆ ParseTextPosition()

AX_BASE_EXPORT ax::mojom::TextPosition ui::ParseTextPosition ( const char *  text_position)

Definition at line 2368 of file ax_enum_util.cc.

2368 {
2369 if (0 == strcmp(text_position, "none"))
2371 if (0 == strcmp(text_position, "subscript"))
2373 if (0 == strcmp(text_position, "superscript"))
2376}

◆ ParseTextStyle()

AX_BASE_EXPORT ax::mojom::TextStyle ui::ParseTextStyle ( const char *  text_style)

Definition at line 2397 of file ax_enum_util.cc.

2397 {
2398 if (0 == strcmp(text_style, "none"))
2400 if (0 == strcmp(text_style, "bold"))
2402 if (0 == strcmp(text_style, "italic"))
2404 if (0 == strcmp(text_style, "underline"))
2406 if (0 == strcmp(text_style, "lineThrough"))
2408 if (0 == strcmp(text_style, "overline"))
2411}

◆ ParseTreeOrder()

AX_BASE_EXPORT ax::mojom::TreeOrder ui::ParseTreeOrder ( const char *  tree_order)

Definition at line 2859 of file ax_enum_util.cc.

2859 {
2860 if (0 == strcmp(tree_order, "none"))
2862 if (0 == strcmp(tree_order, "undefined"))
2864 if (0 == strcmp(tree_order, "before"))
2866 if (0 == strcmp(tree_order, "equal"))
2868 if (0 == strcmp(tree_order, "after"))
2871}

◆ SetActivePopupAxUniqueId()

AX_EXPORT void ui::SetActivePopupAxUniqueId ( std::optional< int32_t >  ax_unique_id)

Definition at line 21 of file ax_active_popup.cc.

21 {
22 // When an instance of autofill popup hides, the caller of popup hide should
23 // make sure g_active_popup_ax_unique_id is cleared. The assumption is that
24 // there can only be one active autofill popup existing at a time. If on
25 // popup showing, we encounter g_active_popup_ax_unique_id is already set,
26 // this would indicate two autofill popups are showing at the same time or
27 // previous on popup hide call did not clear the variable, so we should fail
28 // DCHECK here.
30
31 g_active_popup_ax_unique_id = ax_unique_id;
32}
std::optional< int32_t > GetActivePopupAxUniqueId()
#define BASE_DCHECK(condition)
Definition: logging.h:63

◆ ShouldHaveReadonlyStateByDefault()

AX_BASE_EXPORT bool ui::ShouldHaveReadonlyStateByDefault ( const ax::mojom::Role  role)

Definition at line 774 of file ax_role_properties.cc.

774 {
775 switch (role) {
793 return true;
794
796 // TODO(aleventhal) this changed between ARIA 1.0 and 1.1,
797 // need to determine whether grids/treegrids should really be readonly
798 // or editable by default
799 break;
800
801 default:
802 break;
803 }
804 return false;
805}

◆ StringCompareICU()

static bool ui::StringCompareICU ( BSTR  left,
BSTR  right 
)
static

Definition at line 215 of file ax_platform_node_textrangeprovider_win_unittest.cc.

215 {
216 size_t start, length;
217 if (!StringSearch(reinterpret_cast<char16_t*>(left),
218 reinterpret_cast<char16_t*>(right), &start, &length, true,
219 false)) {
220 return false;
221 }
222 return start == 0 && length == wcslen(left);
223}
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
size_t length
bool StringSearch(std::u16string_view search_string, std::u16string_view find_in, size_t *find_start, size_t *find_length, bool ignore_case, bool backwards)

◆ StringSearch()

bool ui::StringSearch ( std::u16string_view  search_string,
std::u16string_view  find_in,
size_t *  find_start,
size_t *  find_length,
bool  ignore_case,
bool  backwards 
)

Definition at line 453 of file ax_platform_node_textrangeprovider_win.cc.

458 {
459 UErrorCode status = U_ZERO_ERROR;
460 UCollator* col = ucol_open(uloc_getDefault(), &status);
461 UStringSearch* search = usearch_openFromCollator(
462 search_string.data(), search_string.size(), find_in.data(),
463 find_in.size(), col, nullptr, &status);
464 if (!U_SUCCESS(status)) {
465 if (search) {
466 usearch_close(search);
467 }
468 return StringSearchBasic(search_string, find_in, find_start, find_length,
469 backwards);
470 }
471 UCollator* collator = usearch_getCollator(search);
472 ucol_setStrength(collator, ignore_case ? UCOL_PRIMARY : UCOL_TERTIARY);
473 usearch_reset(search);
474 status = U_ZERO_ERROR;
475 usearch_setText(search, find_in.data(), find_in.size(), &status);
476 if (!U_SUCCESS(status)) {
477 if (search) {
478 usearch_close(search);
479 }
480 return StringSearchBasic(search_string, find_in, find_start, find_length,
481 backwards);
482 }
483 int32_t index = backwards ? usearch_last(search, &status)
484 : usearch_first(search, &status);
485 bool match = false;
486 if (U_SUCCESS(status) && index != USEARCH_DONE) {
487 match = true;
488 *find_start = static_cast<size_t>(index);
489 *find_length = static_cast<size_t>(usearch_getMatchedLength(search));
490 }
491 usearch_close(search);
492 return match;
493}
def match(bench, filt)
Definition: benchmark.py:23
static bool StringSearchBasic(const std::u16string_view search_string, const std::u16string_view find_in, size_t *find_start, size_t *find_length, bool backwards)

◆ StringSearchBasic()

static bool ui::StringSearchBasic ( const std::u16string_view  search_string,
const std::u16string_view  find_in,
size_t *  find_start,
size_t *  find_length,
bool  backwards 
)
static

Definition at line 438 of file ax_platform_node_textrangeprovider_win.cc.

442 {
443 size_t index =
444 backwards ? find_in.rfind(search_string) : find_in.find(search_string);
445 if (index == std::u16string::npos) {
446 return false;
447 }
448 *find_start = index;
449 *find_length = search_string.size();
450 return true;
451}

◆ SupportsExpandCollapse()

AX_BASE_EXPORT bool ui::SupportsExpandCollapse ( const ax::mojom::Role  role)

Definition at line 699 of file ax_role_properties.cc.

699 {
700 switch (role) {
706 return true;
707 default:
708 return false;
709 }
710}

◆ SupportsHierarchicalLevel()

AX_BASE_EXPORT bool ui::SupportsHierarchicalLevel ( const ax::mojom::Role  role)

Definition at line 712 of file ax_role_properties.cc.

712 {
713 switch (role) {
719 return true;
720 default:
721 return false;
722 }
723}

◆ SupportsOrientation()

AX_BASE_EXPORT bool ui::SupportsOrientation ( const ax::mojom::Role  role)

Definition at line 725 of file ax_role_properties.cc.

◆ SupportsSelected()

AX_BASE_EXPORT bool ui::SupportsSelected ( const ax::mojom::Role  role)

Definition at line 746 of file ax_role_properties.cc.

746 {
747 switch (role) {
756 return true;
757 default:
758 return false;
759 }
760}

◆ SupportsToggle()

AX_BASE_EXPORT bool ui::SupportsToggle ( const ax::mojom::Role  role)

Definition at line 762 of file ax_role_properties.cc.

762 {
763 switch (role) {
768 return true;
769 default:
770 return false;
771 }
772}

◆ swap() [1/2]

template<class AXPositionType , class AXNodeType >
void ui::swap ( AXPosition< AXPositionType, AXNodeType > &  first,
AXPosition< AXPositionType, AXNodeType > &  second 
)

Definition at line 4022 of file ax_position.h.

4023 {
4024 first.swap(second);
4025}
void swap(AXPosition &other)
Definition: ax_position.h:3171

◆ swap() [2/2]

void ui::swap ( AXTreeID first,
AXTreeID second 
)

Definition at line 65 of file ax_tree_id.cc.

65 {
66 std::swap(first.type_, second.type_);
67 std::swap(first.token_, second.token_);
68}
void swap(sk_sp< T > &a, sk_sp< T > &b)
Definition: SkRefCnt.h:341

◆ TEST() [1/215]

ui::TEST ( AXEnumUtilTest  ,
Action   
)

Definition at line 86 of file ax_enum_util_unittest.cc.

86 {
87 TestEnumStringConversion<ax::mojom::Action>(ParseAction);
88}
ax::mojom::Action ParseAction(const char *action)

◆ TEST() [2/215]

ui::TEST ( AXEnumUtilTest  ,
ActionFlags   
)

Definition at line 90 of file ax_enum_util_unittest.cc.

90 {
91 TestEnumStringConversion<ax::mojom::ActionFlags>(ParseActionFlags);
92}
ax::mojom::ActionFlags ParseActionFlags(const char *action_flags)

◆ TEST() [3/215]

ui::TEST ( AXEnumUtilTest  ,
AriaCurrentState   
)

Definition at line 189 of file ax_enum_util_unittest.cc.

189 {
190 TestEnumStringConversion<ax::mojom::AriaCurrentState>(ParseAriaCurrentState);
191}
ax::mojom::AriaCurrentState ParseAriaCurrentState(const char *aria_current_state)

◆ TEST() [4/215]

ui::TEST ( AXEnumUtilTest  ,
BoolAttribute   
)

Definition at line 121 of file ax_enum_util_unittest.cc.

121 {
122 TestEnumStringConversion<ax::mojom::BoolAttribute>(ParseBoolAttribute);
123 TestAXNodeDataSetter<ax::mojom::BoolAttribute>(&AXNodeData::AddBoolAttribute,
124 false);
125}
ax::mojom::BoolAttribute ParseBoolAttribute(const char *bool_attribute)

◆ TEST() [5/215]

ui::TEST ( AXEnumUtilTest  ,
CheckedState   
)

Definition at line 205 of file ax_enum_util_unittest.cc.

205 {
206 TestEnumStringConversion<ax::mojom::CheckedState>(ParseCheckedState);
207}
ax::mojom::CheckedState ParseCheckedState(const char *checked_state)

◆ TEST() [6/215]

ui::TEST ( AXEnumUtilTest  ,
Command   
)

Definition at line 165 of file ax_enum_util_unittest.cc.

165 {
166 TestEnumStringConversion<ax::mojom::Command>(ParseCommand);
167}
ax::mojom::Command ParseCommand(const char *command)

◆ TEST() [7/215]

ui::TEST ( AXEnumUtilTest  ,
DefaultActionVerb   
)

Definition at line 94 of file ax_enum_util_unittest.cc.

94 {
95 TestEnumStringConversion<ax::mojom::DefaultActionVerb>(
97}
ax::mojom::DefaultActionVerb ParseDefaultActionVerb(const char *default_action_verb)

◆ TEST() [8/215]

ui::TEST ( AXEnumUtilTest  ,
DescriptionFrom   
)

Definition at line 217 of file ax_enum_util_unittest.cc.

217 {
218 TestEnumStringConversion<ax::mojom::DescriptionFrom>(ParseDescriptionFrom);
219}
ax::mojom::DescriptionFrom ParseDescriptionFrom(const char *description_from)

◆ TEST() [9/215]

ui::TEST ( AXEnumUtilTest  ,
Dropeffect   
)

Definition at line 242 of file ax_enum_util_unittest.cc.

242 {
243 TestEnumStringConversion<ax::mojom::Dropeffect>(ParseDropeffect);
244}
ax::mojom::Dropeffect ParseDropeffect(const char *dropeffect)

◆ TEST() [10/215]

ui::TEST ( AXEnumUtilTest  ,
Event   
)

Definition at line 74 of file ax_enum_util_unittest.cc.

74 {
75 TestEnumStringConversion<ax::mojom::Event>(ParseEvent);
76}
ax::mojom::Event ParseEvent(const char *event)

◆ TEST() [11/215]

ui::TEST ( AXEnumUtilTest  ,
EventFrom   
)

Definition at line 221 of file ax_enum_util_unittest.cc.

221 {
222 TestEnumStringConversion<ax::mojom::EventFrom>(ParseEventFrom);
223}
ax::mojom::EventFrom ParseEventFrom(const char *event_from)

◆ TEST() [12/215]

ui::TEST ( AXEnumUtilTest  ,
FloatAttribute   
)

Definition at line 115 of file ax_enum_util_unittest.cc.

115 {
116 TestEnumStringConversion<ax::mojom::FloatAttribute>(ParseFloatAttribute);
117 TestAXNodeDataSetter<ax::mojom::FloatAttribute>(
118 &AXNodeData::AddFloatAttribute, 0.0f);
119}
ax::mojom::FloatAttribute ParseFloatAttribute(const char *float_attribute)

◆ TEST() [13/215]

ui::TEST ( AXEnumUtilTest  ,
Gesture   
)

Definition at line 225 of file ax_enum_util_unittest.cc.

225 {
226 TestEnumStringConversion<ax::mojom::Gesture>(ParseGesture);
227}
ax::mojom::Gesture ParseGesture(const char *gesture)

◆ TEST() [14/215]

ui::TEST ( AXEnumUtilTest  ,
HasPopup   
)

Definition at line 193 of file ax_enum_util_unittest.cc.

193 {
194 TestEnumStringConversion<ax::mojom::HasPopup>(ParseHasPopup);
195}
ax::mojom::HasPopup ParseHasPopup(const char *has_popup)

◆ TEST() [15/215]

ui::TEST ( AXEnumUtilTest  ,
ImageAnnotationStatus   
)

Definition at line 237 of file ax_enum_util_unittest.cc.

237 {
238 TestEnumStringConversion<ax::mojom::ImageAnnotationStatus>(
240}
ax::mojom::ImageAnnotationStatus ParseImageAnnotationStatus(const char *status)

◆ TEST() [16/215]

ui::TEST ( AXEnumUtilTest  ,
IntAttribute   
)

Definition at line 109 of file ax_enum_util_unittest.cc.

109 {
110 TestEnumStringConversion<ax::mojom::IntAttribute>(ParseIntAttribute);
111 TestAXNodeDataSetter<ax::mojom::IntAttribute>(&AXNodeData::AddIntAttribute,
112 0);
113}
ax::mojom::IntAttribute ParseIntAttribute(const char *int_attribute)

◆ TEST() [17/215]

ui::TEST ( AXEnumUtilTest  ,
IntListAttribute   
)

Definition at line 127 of file ax_enum_util_unittest.cc.

127 {
128 TestEnumStringConversion<ax::mojom::IntListAttribute>(ParseIntListAttribute);
129 TestAXNodeDataSetter<ax::mojom::IntListAttribute>(
130 &AXNodeData::AddIntListAttribute, std::vector<int32_t>());
131}
ax::mojom::IntListAttribute ParseIntListAttribute(const char *int_list_attribute)

◆ TEST() [18/215]

ui::TEST ( AXEnumUtilTest  ,
InvalidState   
)

Definition at line 197 of file ax_enum_util_unittest.cc.

197 {
198 TestEnumStringConversion<ax::mojom::InvalidState>(ParseInvalidState);
199}
ax::mojom::InvalidState ParseInvalidState(const char *invalid_state)

◆ TEST() [19/215]

ui::TEST ( AXEnumUtilTest  ,
ListStyle   
)

Definition at line 157 of file ax_enum_util_unittest.cc.

157 {
158 TestEnumStringConversion<ax::mojom::ListStyle>(ParseListStyle);
159}
ax::mojom::ListStyle ParseListStyle(const char *list_style)

◆ TEST() [20/215]

ui::TEST ( AXEnumUtilTest  ,
MarkerType   
)

Definition at line 140 of file ax_enum_util_unittest.cc.

140 {
141 TestEnumStringConversion<ax::mojom::MarkerType>(
142 ParseMarkerType, [](int32_t val) {
143 return val == 0 ? 1 :
144 // 8 (Composition) is
145 // explicitly skipped in
146 // ax_enums.mojom.
147 val == 4 ? 16
148 : val * 2;
149 });
150}
ax::mojom::MarkerType ParseMarkerType(const char *marker_type)

◆ TEST() [21/215]

ui::TEST ( AXEnumUtilTest  ,
MoveDirection   
)

Definition at line 161 of file ax_enum_util_unittest.cc.

161 {
162 TestEnumStringConversion<ax::mojom::MoveDirection>(ParseMoveDirection);
163}
ax::mojom::MoveDirection ParseMoveDirection(const char *move_direction)

◆ TEST() [22/215]

ui::TEST ( AXEnumUtilTest  ,
Mutation   
)

Definition at line 99 of file ax_enum_util_unittest.cc.

99 {
100 TestEnumStringConversion<ax::mojom::Mutation>(ParseMutation);
101}
ax::mojom::Mutation ParseMutation(const char *mutation)

◆ TEST() [23/215]

ui::TEST ( AXEnumUtilTest  ,
NameFrom   
)

Definition at line 213 of file ax_enum_util_unittest.cc.

213 {
214 TestEnumStringConversion<ax::mojom::NameFrom>(ParseNameFrom);
215}
ax::mojom::NameFrom ParseNameFrom(const char *name_from)

◆ TEST() [24/215]

ui::TEST ( AXEnumUtilTest  ,
Restriction   
)

Definition at line 201 of file ax_enum_util_unittest.cc.

201 {
202 TestEnumStringConversion<ax::mojom::Restriction>(ParseRestriction);
203}
ax::mojom::Restriction ParseRestriction(const char *restriction)

◆ TEST() [25/215]

ui::TEST ( AXEnumUtilTest  ,
Role   
)

Definition at line 78 of file ax_enum_util_unittest.cc.

78 {
79 TestEnumStringConversion<ax::mojom::Role>(ParseRole);
80}
ax::mojom::Role ParseRole(const char *role)

◆ TEST() [26/215]

ui::TEST ( AXEnumUtilTest  ,
SortDirection   
)

Definition at line 209 of file ax_enum_util_unittest.cc.

209 {
210 TestEnumStringConversion<ax::mojom::SortDirection>(ParseSortDirection);
211}
ax::mojom::SortDirection ParseSortDirection(const char *sort_direction)

◆ TEST() [27/215]

ui::TEST ( AXEnumUtilTest  ,
State   
)

Definition at line 82 of file ax_enum_util_unittest.cc.

82 {
83 TestEnumStringConversion<ax::mojom::State>(ParseState);
84}
ax::mojom::State ParseState(const char *state)

◆ TEST() [28/215]

ui::TEST ( AXEnumUtilTest  ,
StringAttribute   
)

Definition at line 103 of file ax_enum_util_unittest.cc.

103 {
104 TestEnumStringConversion<ax::mojom::StringAttribute>(ParseStringAttribute);
105 TestAXNodeDataSetter<ax::mojom::StringAttribute>(
106 &AXNodeData::AddStringAttribute, std::string());
107}
ax::mojom::StringAttribute ParseStringAttribute(const char *string_attribute)

◆ TEST() [29/215]

ui::TEST ( AXEnumUtilTest  ,
StringListAttribute   
)

Definition at line 133 of file ax_enum_util_unittest.cc.

133 {
134 TestEnumStringConversion<ax::mojom::StringListAttribute>(
136 TestAXNodeDataSetter<ax::mojom::StringListAttribute>(
137 &AXNodeData::AddStringListAttribute, std::vector<std::string>());
138}
ax::mojom::StringListAttribute ParseStringListAttribute(const char *string_list_attribute)

◆ TEST() [30/215]

ui::TEST ( AXEnumUtilTest  ,
Text_Decoration_Style   
)

Definition at line 152 of file ax_enum_util_unittest.cc.

152 {
153 TestEnumStringConversion<ax::mojom::TextDecorationStyle>(
155}
ax::mojom::TextDecorationStyle ParseTextDecorationStyle(const char *text_decoration_style)

◆ TEST() [31/215]

ui::TEST ( AXEnumUtilTest  ,
TextAffinity   
)

Definition at line 229 of file ax_enum_util_unittest.cc.

229 {
230 TestEnumStringConversion<ax::mojom::TextAffinity>(ParseTextAffinity);
231}
ax::mojom::TextAffinity ParseTextAffinity(const char *text_affinity)

◆ TEST() [32/215]

ui::TEST ( AXEnumUtilTest  ,
TextAlign   
)

Definition at line 169 of file ax_enum_util_unittest.cc.

169 {
170 TestEnumStringConversion<ax::mojom::TextAlign>(ParseTextAlign);
171}
ax::mojom::TextAlign ParseTextAlign(const char *text_align)

◆ TEST() [33/215]

ui::TEST ( AXEnumUtilTest  ,
TextBoundary   
)

Definition at line 173 of file ax_enum_util_unittest.cc.

173 {
174 TestEnumStringConversion<ax::mojom::TextBoundary>(ParseTextBoundary);
175}
ax::mojom::TextBoundary ParseTextBoundary(const char *text_boundary)

◆ TEST() [34/215]

ui::TEST ( AXEnumUtilTest  ,
TextDirection   
)

Definition at line 177 of file ax_enum_util_unittest.cc.

177 {
178 TestEnumStringConversion<ax::mojom::WritingDirection>(ParseTextDirection);
179}
ax::mojom::WritingDirection ParseTextDirection(const char *text_direction)

◆ TEST() [35/215]

ui::TEST ( AXEnumUtilTest  ,
TextPosition   
)

Definition at line 181 of file ax_enum_util_unittest.cc.

181 {
182 TestEnumStringConversion<ax::mojom::TextPosition>(ParseTextPosition);
183}
ax::mojom::TextPosition ParseTextPosition(const char *text_position)

◆ TEST() [36/215]

ui::TEST ( AXEnumUtilTest  ,
TextStyle   
)

Definition at line 185 of file ax_enum_util_unittest.cc.

185 {
186 TestEnumStringConversion<ax::mojom::TextStyle>(ParseTextStyle);
187}
ax::mojom::TextStyle ParseTextStyle(const char *text_style)

◆ TEST() [37/215]

ui::TEST ( AXEnumUtilTest  ,
TreeOrder   
)

Definition at line 233 of file ax_enum_util_unittest.cc.

233 {
234 TestEnumStringConversion<ax::mojom::TreeOrder>(ParseTreeOrder);
235}
ax::mojom::TreeOrder ParseTreeOrder(const char *tree_order)

◆ TEST() [38/215]

ui::TEST ( AXEventGeneratorTest  ,
ActiveDescendantChanged   
)

Definition at line 404 of file ax_event_generator_unittest.cc.

404 {
405 AXTreeUpdate initial_state;
406 initial_state.root_id = 1;
407 initial_state.nodes.resize(3);
408 initial_state.nodes[0].id = 1;
409 initial_state.nodes[0].role = ax::mojom::Role::kListBox;
410 initial_state.nodes[0].child_ids.push_back(2);
411 initial_state.nodes[0].child_ids.push_back(3);
412 initial_state.nodes[0].AddIntAttribute(
414 initial_state.nodes[1].id = 2;
415 initial_state.nodes[1].role = ax::mojom::Role::kListBoxOption;
416 initial_state.nodes[2].id = 3;
417 initial_state.nodes[2].role = ax::mojom::Role::kListBoxOption;
418 AXTree tree(initial_state);
419
420 AXEventGenerator event_generator(&tree);
421 AXTreeUpdate update = initial_state;
422 update.nodes[0].int_attributes.clear();
424 3);
425 ASSERT_TRUE(tree.Unserialize(update));
426 EXPECT_TRUE(HasEvent(event_generator,
427 AXEventGenerator::Event::ACTIVE_DESCENDANT_CHANGED, 1));
428 EXPECT_TRUE(HasEvent(event_generator,
429 AXEventGenerator::Event::RELATED_NODE_CHANGED, 1));
430}
Definition: update.py:1
std::vector< AXNodeData > nodes
#define EXPECT_TRUE(handle)
Definition: unit_test.h:678

◆ TEST() [39/215]

ui::TEST ( AXEventGeneratorTest  ,
ActiveDescendantChangeOnDescendant   
)

Definition at line 1769 of file ax_event_generator_unittest.cc.

1769 {
1770 AXTreeUpdate initial_state;
1771 initial_state.root_id = 1;
1772 initial_state.nodes.resize(5);
1773 initial_state.nodes[0].id = 1;
1774 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
1775 initial_state.nodes[0].child_ids.push_back(2);
1776 initial_state.nodes[1].id = 2;
1777 initial_state.nodes[1].role = ax::mojom::Role::kGenericContainer;
1778 initial_state.nodes[1].child_ids.push_back(3);
1779 initial_state.nodes[2].id = 3;
1780 initial_state.nodes[2].role = ax::mojom::Role::kGroup;
1781 initial_state.nodes[2].AddIntAttribute(
1783 initial_state.nodes[2].child_ids.push_back(4);
1784 initial_state.nodes[2].child_ids.push_back(5);
1785 initial_state.nodes[3].id = 4;
1786 initial_state.nodes[3].role = ax::mojom::Role::kGroup;
1787 initial_state.nodes[4].id = 5;
1788 initial_state.nodes[4].role = ax::mojom::Role::kGroup;
1789
1790 AXTree tree(initial_state);
1791
1792 AXEventGenerator event_generator(&tree);
1793 initial_state.nodes[2].RemoveIntAttribute(
1795 initial_state.nodes[2].AddIntAttribute(
1797 AXTreeUpdate update = initial_state;
1798 update.node_id_to_clear = 2;
1799 ASSERT_TRUE(tree.Unserialize(update));
1800 EXPECT_TRUE(HasEvent(event_generator,
1801 AXEventGenerator::Event::ACTIVE_DESCENDANT_CHANGED, 3));
1802 EXPECT_TRUE(HasEvent(event_generator,
1803 AXEventGenerator::Event::RELATED_NODE_CHANGED, 3));
1804}

◆ TEST() [40/215]

ui::TEST ( AXEventGeneratorTest  ,
AddChild   
)

Definition at line 616 of file ax_event_generator_unittest.cc.

616 {
617 AXTreeUpdate initial_state;
618 initial_state.root_id = 1;
619 initial_state.nodes.resize(2);
620 initial_state.nodes[0].id = 1;
621 initial_state.nodes[0].child_ids.push_back(2);
622 initial_state.nodes[1].id = 2;
623 AXTree tree(initial_state);
624
625 AXEventGenerator event_generator(&tree);
626 AXTreeUpdate update = initial_state;
627 update.nodes.resize(3);
628 update.nodes[0].child_ids.push_back(3);
629 update.nodes[2].id = 3;
630
631 ASSERT_TRUE(tree.Unserialize(update));
633 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 1));
635 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 3));
636}

◆ TEST() [41/215]

ui::TEST ( AXEventGeneratorTest  ,
AddLiveRegionAttribute   
)

Definition at line 352 of file ax_event_generator_unittest.cc.

352 {
353 AXTreeUpdate initial_state;
354 initial_state.root_id = 1;
355 initial_state.nodes.resize(1);
356 initial_state.nodes[0].id = 1;
357 AXTree tree(initial_state);
358
359 AXEventGenerator event_generator(&tree);
360 AXTreeUpdate update = initial_state;
361 update.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kLiveStatus,
362 "polite");
363 ASSERT_TRUE(tree.Unserialize(update));
364 EXPECT_TRUE(HasEvent(event_generator,
365 AXEventGenerator::Event::LIVE_STATUS_CHANGED, 1));
366 EXPECT_TRUE(HasEvent(event_generator,
367 AXEventGenerator::Event::LIVE_REGION_CREATED, 1));
368
369 event_generator.ClearEvents();
370 update.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kLiveStatus,
371 "assertive");
372 ASSERT_TRUE(tree.Unserialize(update));
373 EXPECT_TRUE(HasEvent(event_generator,
374 AXEventGenerator::Event::LIVE_STATUS_CHANGED, 1));
375
376 event_generator.ClearEvents();
377 update.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kLiveStatus,
378 "off");
379
380 ASSERT_TRUE(tree.Unserialize(update));
381 EXPECT_TRUE(HasEvent(event_generator,
382 AXEventGenerator::Event::LIVE_STATUS_CHANGED, 1));
383}

◆ TEST() [42/215]

ui::TEST ( AXEventGeneratorTest  ,
AriaBusyChanged   
)

Definition at line 1976 of file ax_event_generator_unittest.cc.

1976 {
1977 AXTreeUpdate initial_state;
1978 initial_state.root_id = 1;
1979 initial_state.nodes.resize(1);
1980 initial_state.nodes[0].id = 1;
1981 AXTree tree(initial_state);
1982 initial_state.nodes[0].AddBoolAttribute(ax::mojom::BoolAttribute::kBusy,
1983 true);
1984
1985 AXEventGenerator event_generator(&tree);
1986 AXTreeUpdate update = initial_state;
1987 update.nodes[0].AddBoolAttribute(ax::mojom::BoolAttribute::kBusy, false);
1988
1989 ASSERT_TRUE(tree.Unserialize(update));
1991 HasEvent(event_generator, AXEventGenerator::Event::BUSY_CHANGED, 1));
1992 EXPECT_TRUE(HasEvent(event_generator,
1993 AXEventGenerator::Event::LAYOUT_INVALIDATED, 1));
1994 EXPECT_TRUE(HasEvent(event_generator,
1995 AXEventGenerator::Event::WIN_IACCESSIBLE_STATE_CHANGED,
1996 1));
1997}

◆ TEST() [43/215]

ui::TEST ( AXEventGeneratorTest  ,
AtomicChanged   
)

Definition at line 2106 of file ax_event_generator_unittest.cc.

2106 {
2107 AXTreeUpdate initial_state;
2108 initial_state.root_id = 1;
2109 initial_state.nodes.resize(1);
2110 initial_state.nodes[0].id = 1;
2111
2112 AXTree tree(initial_state);
2113 AXEventGenerator event_generator(&tree);
2114 AXTreeUpdate update = initial_state;
2115
2116 update.nodes[0].AddBoolAttribute(ax::mojom::BoolAttribute::kLiveAtomic, true);
2117 EXPECT_TRUE(tree.Unserialize(update));
2119 HasEvent(event_generator, AXEventGenerator::Event::ATOMIC_CHANGED, 1));
2120}

◆ TEST() [44/215]

ui::TEST ( AXEventGeneratorTest  ,
BusyLiveRegionChanged   
)

Definition at line 569 of file ax_event_generator_unittest.cc.

569 {
570 AXTreeUpdate initial_state;
571 initial_state.root_id = 1;
572 initial_state.nodes.resize(3);
573 initial_state.nodes[0].id = 1;
574 initial_state.nodes[0].AddStringAttribute(
576 initial_state.nodes[0].AddStringAttribute(
578 initial_state.nodes[0].AddBoolAttribute(ax::mojom::BoolAttribute::kBusy,
579 true);
580 initial_state.nodes[0].child_ids.push_back(2);
581 initial_state.nodes[0].child_ids.push_back(3);
582 initial_state.nodes[1].id = 2;
583 initial_state.nodes[1].role = ax::mojom::Role::kStaticText;
584 initial_state.nodes[1].AddStringAttribute(
586 initial_state.nodes[1].AddStringAttribute(ax::mojom::StringAttribute::kName,
587 "Before 1");
588 initial_state.nodes[2].id = 3;
589 initial_state.nodes[2].role = ax::mojom::Role::kStaticText;
590 initial_state.nodes[2].AddStringAttribute(
592 initial_state.nodes[2].AddStringAttribute(ax::mojom::StringAttribute::kName,
593 "Before 2");
594 AXTree tree(initial_state);
595
596 AXEventGenerator event_generator(&tree);
597 AXTreeUpdate update = initial_state;
598 update.nodes[1].string_attributes.clear();
599 update.nodes[1].AddStringAttribute(
601 update.nodes[1].AddStringAttribute(ax::mojom::StringAttribute::kName,
602 "After 1");
603 update.nodes[2].string_attributes.clear();
604 update.nodes[2].AddStringAttribute(
606 update.nodes[2].AddStringAttribute(ax::mojom::StringAttribute::kName,
607 "After 2");
608
609 ASSERT_TRUE(tree.Unserialize(update));
611 HasEvent(event_generator, AXEventGenerator::Event::NAME_CHANGED, 2));
613 HasEvent(event_generator, AXEventGenerator::Event::NAME_CHANGED, 3));
614}

◆ TEST() [45/215]

ui::TEST ( AXEventGeneratorTest  ,
CheckedStateChanged   
)

Definition at line 385 of file ax_event_generator_unittest.cc.

385 {
386 AXTreeUpdate initial_state;
387 initial_state.root_id = 1;
388 initial_state.nodes.resize(1);
389 initial_state.nodes[0].id = 1;
390 initial_state.nodes[0].role = ax::mojom::Role::kCheckBox;
391 AXTree tree(initial_state);
392
393 AXEventGenerator event_generator(&tree);
394 AXTreeUpdate update = initial_state;
395 update.nodes[0].SetCheckedState(ax::mojom::CheckedState::kTrue);
396 ASSERT_TRUE(tree.Unserialize(update));
397 EXPECT_TRUE(HasEvent(event_generator,
398 AXEventGenerator::Event::CHECKED_STATE_CHANGED, 1));
399 EXPECT_TRUE(HasEvent(event_generator,
400 AXEventGenerator::Event::WIN_IACCESSIBLE_STATE_CHANGED,
401 1));
402}

◆ TEST() [46/215]

ui::TEST ( AXEventGeneratorTest  ,
ControlsChanged   
)

Definition at line 2084 of file ax_event_generator_unittest.cc.

2084 {
2085 AXTreeUpdate initial_state;
2086 initial_state.root_id = 1;
2087 initial_state.nodes.resize(2);
2088 initial_state.nodes[0].id = 1;
2089 initial_state.nodes[0].child_ids.push_back(2);
2090 initial_state.nodes[1].id = 2;
2091
2092 AXTree tree(initial_state);
2093 AXEventGenerator event_generator(&tree);
2094 AXTreeUpdate update = initial_state;
2095
2096 std::vector<int> ids = {2};
2097 update.nodes[0].AddIntListAttribute(ax::mojom::IntListAttribute::kControlsIds,
2098 ids);
2099 EXPECT_TRUE(tree.Unserialize(update));
2101 HasEvent(event_generator, AXEventGenerator::Event::CONTROLS_CHANGED, 1));
2102 EXPECT_TRUE(HasEvent(event_generator,
2103 AXEventGenerator::Event::RELATED_NODE_CHANGED, 1));
2104}

◆ TEST() [47/215]

ui::TEST ( AXEventGeneratorTest  ,
CreateAlertAndLiveRegion   
)

Definition at line 432 of file ax_event_generator_unittest.cc.

432 {
433 AXTreeUpdate initial_state;
434 initial_state.root_id = 1;
435 initial_state.nodes.resize(1);
436 initial_state.nodes[0].id = 1;
437 AXTree tree(initial_state);
438
439 AXEventGenerator event_generator(&tree);
440 AXTreeUpdate update = initial_state;
441 update.nodes.resize(4);
442 update.nodes[0].child_ids.push_back(2);
443 update.nodes[0].child_ids.push_back(3);
444 update.nodes[0].child_ids.push_back(4);
445
446 update.nodes[1].id = 2;
447 update.nodes[1].AddStringAttribute(ax::mojom::StringAttribute::kLiveStatus,
448 "polite");
449
450 // Blink should automatically add aria-live="assertive" to elements with role
451 // kAlert, but we should fire an alert event regardless.
452 update.nodes[2].id = 3;
453 update.nodes[2].role = ax::mojom::Role::kAlert;
454
455 // Elements with role kAlertDialog will *not* usually have a live region
456 // status, but again, we should always fire an alert event.
457 update.nodes[3].id = 4;
459
460 ASSERT_TRUE(tree.Unserialize(update));
461 EXPECT_TRUE(HasEvent(event_generator, AXEventGenerator::Event::ALERT, 3));
462 EXPECT_TRUE(HasEvent(event_generator, AXEventGenerator::Event::ALERT, 4));
464 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 1));
465 EXPECT_TRUE(HasEvent(event_generator,
466 AXEventGenerator::Event::LIVE_REGION_CREATED, 2));
468 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 2));
470 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 3));
472 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 4));
473}

◆ TEST() [48/215]

ui::TEST ( AXEventGeneratorTest  ,
DescriptionChanged   
)

Definition at line 917 of file ax_event_generator_unittest.cc.

917 {
918 AXTreeUpdate initial_state;
919 initial_state.root_id = 1;
920 initial_state.nodes.resize(1);
921 initial_state.nodes[0].id = 1;
922 AXTree tree(initial_state);
923
924 AXEventGenerator event_generator(&tree);
925 AXTreeUpdate update = initial_state;
926 update.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kDescription,
927 "Hello");
928 ASSERT_TRUE(tree.Unserialize(update));
929 EXPECT_TRUE(HasEvent(event_generator,
930 AXEventGenerator::Event::DESCRIPTION_CHANGED, 1));
931}

◆ TEST() [49/215]

ui::TEST ( AXEventGeneratorTest  ,
DocumentSelectionChanged   
)

Definition at line 130 of file ax_event_generator_unittest.cc.

130 {
131 AXTreeUpdate initial_state;
132 initial_state.root_id = 1;
133 initial_state.nodes.resize(1);
134 initial_state.nodes[0].id = 1;
135 initial_state.has_tree_data = true;
136 initial_state.tree_data.sel_focus_object_id = 1;
137 initial_state.tree_data.sel_focus_offset = 1;
138 AXTree tree(initial_state);
139
140 AXEventGenerator event_generator(&tree);
141 AXTreeUpdate update = initial_state;
142 update.tree_data.sel_focus_offset = 2;
143
144 ASSERT_TRUE(tree.Unserialize(update));
145 EXPECT_TRUE(HasEvent(event_generator,
146 AXEventGenerator::Event::DOCUMENT_SELECTION_CHANGED, 1));
147}

◆ TEST() [50/215]

ui::TEST ( AXEventGeneratorTest  ,
DocumentTitleChanged   
)

Definition at line 149 of file ax_event_generator_unittest.cc.

149 {
150 AXTreeUpdate initial_state;
151 initial_state.root_id = 1;
152 initial_state.nodes.resize(1);
153 initial_state.nodes[0].id = 1;
154 initial_state.has_tree_data = true;
155 initial_state.tree_data.title = "Before";
156 AXTree tree(initial_state);
157
158 AXEventGenerator event_generator(&tree);
159 AXTreeUpdate update = initial_state;
160 update.tree_data.title = "After";
161
162 ASSERT_TRUE(tree.Unserialize(update));
163 EXPECT_TRUE(HasEvent(event_generator,
164 AXEventGenerator::Event::DOCUMENT_TITLE_CHANGED, 1));
165}

◆ TEST() [51/215]

ui::TEST ( AXEventGeneratorTest  ,
DropeffectChanged   
)

Definition at line 2122 of file ax_event_generator_unittest.cc.

2122 {
2123 AXTreeUpdate initial_state;
2124 initial_state.root_id = 1;
2125 initial_state.nodes.resize(1);
2126 initial_state.nodes[0].id = 1;
2127
2128 AXTree tree(initial_state);
2129 AXEventGenerator event_generator(&tree);
2130 AXTreeUpdate update = initial_state;
2131
2132 update.nodes[0].AddDropeffect(ax::mojom::Dropeffect::kCopy);
2133 EXPECT_TRUE(tree.Unserialize(update));
2134 EXPECT_TRUE(HasEvent(event_generator,
2135 AXEventGenerator::Event::DROPEFFECT_CHANGED, 1));
2136}

◆ TEST() [52/215]

ui::TEST ( AXEventGeneratorTest  ,
ExpandedAndRowCount   
)

Definition at line 209 of file ax_event_generator_unittest.cc.

209 {
210 AXTreeUpdate initial_state;
211 initial_state.root_id = 1;
212 initial_state.nodes.resize(4);
213 initial_state.nodes[0].id = 1;
214 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
215 initial_state.nodes[0].child_ids.push_back(2);
216 initial_state.nodes[0].child_ids.push_back(4);
217 initial_state.nodes[1].id = 2;
218 initial_state.nodes[1].role = ax::mojom::Role::kTable;
219 initial_state.nodes[1].child_ids.push_back(3);
220 initial_state.nodes[2].id = 3;
221 initial_state.nodes[2].role = ax::mojom::Role::kRow;
222 initial_state.nodes[3].id = 4;
223 initial_state.nodes[3].role = ax::mojom::Role::kPopUpButton;
224 initial_state.nodes[3].AddState(ax::mojom::State::kExpanded);
225 AXTree tree(initial_state);
226
227 AXEventGenerator event_generator(&tree);
228 AXTreeUpdate update = initial_state;
229 update.nodes[2].AddState(ax::mojom::State::kExpanded);
230 update.nodes[3].state = 0;
231
232 ASSERT_TRUE(tree.Unserialize(update));
233 EXPECT_TRUE(HasEvent(event_generator, AXEventGenerator::Event::COLLAPSED, 4));
234 EXPECT_TRUE(HasEvent(event_generator, AXEventGenerator::Event::EXPANDED, 3));
236 HasEvent(event_generator, AXEventGenerator::Event::ROW_COUNT_CHANGED, 2));
238 HasEvent(event_generator, AXEventGenerator::Event::STATE_CHANGED, 3));
239 EXPECT_TRUE(HasEvent(event_generator,
240 AXEventGenerator::Event::WIN_IACCESSIBLE_STATE_CHANGED,
241 3));
243 HasEvent(event_generator, AXEventGenerator::Event::STATE_CHANGED, 4));
244 EXPECT_TRUE(HasEvent(event_generator,
245 AXEventGenerator::Event::WIN_IACCESSIBLE_STATE_CHANGED,
246 4));
247}

◆ TEST() [53/215]

ui::TEST ( AXEventGeneratorTest  ,
FloatValueChanged   
)

Definition at line 313 of file ax_event_generator_unittest.cc.

313 {
314 AXTreeUpdate initial_state;
315 initial_state.root_id = 1;
316 initial_state.nodes.resize(1);
317 initial_state.nodes[0].id = 1;
318 initial_state.nodes[0].role = ax::mojom::Role::kSlider;
319 initial_state.nodes[0].AddFloatAttribute(
321 AXTree tree(initial_state);
322
323 AXEventGenerator event_generator(&tree);
324 AXTreeUpdate update = initial_state;
325 update.nodes[0].float_attributes.clear();
326 update.nodes[0].AddFloatAttribute(ax::mojom::FloatAttribute::kValueForRange,
327 2.0);
328
329 ASSERT_TRUE(tree.Unserialize(update));
331 HasEvent(event_generator, AXEventGenerator::Event::VALUE_CHANGED, 1));
332}

◆ TEST() [54/215]

ui::TEST ( AXEventGeneratorTest  ,
FlowToChanged   
)

Definition at line 2044 of file ax_event_generator_unittest.cc.

2044 {
2045 AXTreeUpdate initial_state;
2046 initial_state.root_id = 1;
2047 initial_state.nodes.resize(6);
2048 initial_state.nodes[0].id = 1;
2049 initial_state.nodes[0].role = ax::mojom::Role::kGenericContainer;
2050 initial_state.nodes[0].child_ids.assign({2, 3, 4, 5, 6});
2051 initial_state.nodes[1].id = 2;
2052 initial_state.nodes[1].role = ax::mojom::Role::kGenericContainer;
2053 initial_state.nodes[1].AddIntListAttribute(
2055 initial_state.nodes[2].id = 3;
2056 initial_state.nodes[2].role = ax::mojom::Role::kGenericContainer;
2057 initial_state.nodes[3].id = 4;
2058 initial_state.nodes[3].role = ax::mojom::Role::kGenericContainer;
2059 initial_state.nodes[4].id = 5;
2060 initial_state.nodes[4].role = ax::mojom::Role::kGenericContainer;
2061 initial_state.nodes[5].id = 6;
2062 initial_state.nodes[5].role = ax::mojom::Role::kGenericContainer;
2063
2064 AXTree tree(initial_state);
2065
2066 AXEventGenerator event_generator(&tree);
2067 AXTreeUpdate update = initial_state;
2068 update.nodes[1].AddIntListAttribute(ax::mojom::IntListAttribute::kFlowtoIds,
2069 {4, 5, 6});
2070
2071 EXPECT_TRUE(tree.Unserialize(update));
2073 HasEvent(event_generator, AXEventGenerator::Event::FLOW_FROM_CHANGED, 3));
2075 HasEvent(event_generator, AXEventGenerator::Event::FLOW_FROM_CHANGED, 5));
2077 HasEvent(event_generator, AXEventGenerator::Event::FLOW_FROM_CHANGED, 6));
2079 HasEvent(event_generator, AXEventGenerator::Event::FLOW_TO_CHANGED, 2));
2080 EXPECT_TRUE(HasEvent(event_generator,
2081 AXEventGenerator::Event::RELATED_NODE_CHANGED, 2));
2082}
AXTreeUpdateBase< AXNodeData, AXTreeData > AXTreeUpdate

◆ TEST() [55/215]

ui::TEST ( AXEventGeneratorTest  ,
FocusIdChanged   
)

Definition at line 189 of file ax_event_generator_unittest.cc.

189 {
190 AXTreeUpdate initial_state;
191 initial_state.root_id = 1;
192 initial_state.nodes.resize(2);
193 initial_state.nodes[0].id = 1;
194 initial_state.nodes[0].child_ids.push_back(2);
195 initial_state.nodes[1].id = 2;
196 initial_state.has_tree_data = true;
197 initial_state.tree_data.focus_id = 1;
198 AXTree tree(initial_state);
199
200 AXEventGenerator event_generator(&tree);
201 AXTreeUpdate update = initial_state;
202 update.tree_data.focus_id = 2;
203
204 ASSERT_TRUE(tree.Unserialize(update));
206 HasEvent(event_generator, AXEventGenerator::Event::FOCUS_CHANGED, 2));
207}

◆ TEST() [56/215]

ui::TEST ( AXEventGeneratorTest  ,
FocusIdUnchanged   
)

Definition at line 168 of file ax_event_generator_unittest.cc.

168 {
169 AXTreeUpdate initial_state;
170 initial_state.root_id = 1;
171 initial_state.nodes.resize(2);
172 initial_state.nodes[0].id = 1;
173 initial_state.nodes[0].child_ids.push_back(2);
174 initial_state.nodes[1].id = 2;
175 initial_state.has_tree_data = true;
176 initial_state.tree_data.focus_id = 1;
177 AXTree tree(initial_state);
178
179 AXEventGenerator event_generator(&tree);
180 AXTreeUpdate update = initial_state;
181 update.tree_data.focus_id = 1;
182
183 ASSERT_TRUE(tree.Unserialize(update));
184 EXPECT_FALSE(
185 HasEvent(event_generator, AXEventGenerator::Event::FOCUS_CHANGED, 1));
186}

◆ TEST() [57/215]

ui::TEST ( AXEventGeneratorTest  ,
GrabbedChanged   
)

Definition at line 2138 of file ax_event_generator_unittest.cc.

2138 {
2139 AXTreeUpdate initial_state;
2140 initial_state.root_id = 1;
2141 initial_state.nodes.resize(1);
2142 initial_state.nodes[0].id = 1;
2143
2144 AXTree tree(initial_state);
2145 AXEventGenerator event_generator(&tree);
2146 AXTreeUpdate update = initial_state;
2147
2148 update.nodes[0].AddBoolAttribute(ax::mojom::BoolAttribute::kGrabbed, true);
2149 EXPECT_TRUE(tree.Unserialize(update));
2151 HasEvent(event_generator, AXEventGenerator::Event::GRABBED_CHANGED, 1));
2152}

◆ TEST() [58/215]

ui::TEST ( AXEventGeneratorTest  ,
HasPopupChanged   
)

Definition at line 2154 of file ax_event_generator_unittest.cc.

2154 {
2155 AXTreeUpdate initial_state;
2156 initial_state.root_id = 1;
2157 initial_state.nodes.resize(1);
2158 initial_state.nodes[0].id = 1;
2159
2160 AXTree tree(initial_state);
2161 AXEventGenerator event_generator(&tree);
2162 AXTreeUpdate update = initial_state;
2163
2164 update.nodes[0].SetHasPopup(ax::mojom::HasPopup::kTrue);
2165 EXPECT_TRUE(tree.Unserialize(update));
2167 HasEvent(event_generator, AXEventGenerator::Event::HASPOPUP_CHANGED, 1));
2168 EXPECT_TRUE(HasEvent(event_generator,
2169 AXEventGenerator::Event::WIN_IACCESSIBLE_STATE_CHANGED,
2170 1));
2171}

◆ TEST() [59/215]

ui::TEST ( AXEventGeneratorTest  ,
IgnoredChangedFiredOnAncestorOnly1   
)

Definition at line 1212 of file ax_event_generator_unittest.cc.

1212 {
1213 // BEFORE
1214 // 1 (IGN)
1215 // / \
1216 // 2 3 (IGN)
1217
1218 // AFTER
1219 // 1 (IGN)
1220 // / \
1221 // 2 (IGN) 3
1222 // IGNORED_CHANGED expected on #2, #3
1223
1224 AXTreeUpdate initial_state;
1225 initial_state.root_id = 1;
1226 initial_state.nodes.resize(3);
1227 initial_state.nodes[0].id = 1;
1228 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
1229 initial_state.nodes[0].AddState(ax::mojom::State::kIgnored);
1230 initial_state.nodes[0].child_ids = {2, 3};
1231
1232 initial_state.nodes[1].id = 2;
1233 initial_state.nodes[1].role = ax::mojom::Role::kStaticText;
1234
1235 initial_state.nodes[2].id = 3;
1236 initial_state.nodes[2].role = ax::mojom::Role::kStaticText;
1237 initial_state.nodes[2].AddState(ax::mojom::State::kIgnored);
1238
1239 AXTree tree(initial_state);
1240
1241 AXEventGenerator event_generator(&tree);
1242 AXTreeUpdate update = initial_state;
1243 update.nodes[1].AddState(ax::mojom::State::kIgnored);
1244 update.nodes[2].RemoveState(ax::mojom::State::kIgnored);
1245 ASSERT_TRUE(tree.Unserialize(update));
1247 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 2));
1249 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 3));
1251 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 3));
1252}

◆ TEST() [60/215]

ui::TEST ( AXEventGeneratorTest  ,
IgnoredChangedFiredOnAncestorOnly2   
)

Definition at line 1254 of file ax_event_generator_unittest.cc.

1254 {
1255 // BEFORE
1256 // 1
1257 // |
1258 // 2
1259 // / \
1260 // 3 4 (IGN)
1261
1262 // AFTER
1263 // 1
1264 // |
1265 // 2 ___
1266 // / \
1267 // 3 (IGN) 4
1268 // IGNORED_CHANGED expected on #3, #4
1269
1270 AXTreeUpdate initial_state;
1271 initial_state.root_id = 1;
1272 initial_state.nodes.resize(4);
1273 initial_state.nodes[0].id = 1;
1274 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
1275 initial_state.nodes[0].child_ids = {2};
1276
1277 initial_state.nodes[1].id = 2;
1278 initial_state.nodes[1].role = ax::mojom::Role::kGroup;
1279 initial_state.nodes[1].child_ids = {3, 4};
1280
1281 initial_state.nodes[2].id = 3;
1282 initial_state.nodes[2].role = ax::mojom::Role::kStaticText;
1283
1284 initial_state.nodes[3].id = 4;
1285 initial_state.nodes[3].role = ax::mojom::Role::kStaticText;
1286 initial_state.nodes[3].AddState(ax::mojom::State::kIgnored);
1287
1288 AXTree tree(initial_state);
1289
1290 AXEventGenerator event_generator(&tree);
1291 AXTreeUpdate update = initial_state;
1292 update.nodes[2].AddState(ax::mojom::State::kIgnored);
1293 update.nodes[3].RemoveState(ax::mojom::State::kIgnored);
1294 ASSERT_TRUE(tree.Unserialize(update));
1296 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 2));
1298 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 3));
1300 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 4));
1302 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 4));
1303}

◆ TEST() [61/215]

ui::TEST ( AXEventGeneratorTest  ,
IgnoredChangedFiredOnAncestorOnly3   
)

Definition at line 1305 of file ax_event_generator_unittest.cc.

1305 {
1306 // BEFORE
1307 // 1
1308 // |
1309 // 2 ___
1310 // / \
1311 // 3 (IGN) 4
1312
1313 // AFTER
1314 // 1 (IGN)
1315 // |
1316 // 2
1317 // / \
1318 // 3 4 (IGN)
1319 // IGNORED_CHANGED expected on #1, #3
1320
1321 AXTreeUpdate initial_state;
1322 initial_state.root_id = 1;
1323 initial_state.nodes.resize(4);
1324 initial_state.nodes[0].id = 1;
1325 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
1326 initial_state.nodes[0].child_ids = {2};
1327
1328 initial_state.nodes[1].id = 2;
1329 initial_state.nodes[1].role = ax::mojom::Role::kGroup;
1330 initial_state.nodes[1].child_ids = {3, 4};
1331
1332 initial_state.nodes[2].id = 3;
1333 initial_state.nodes[2].role = ax::mojom::Role::kStaticText;
1334 initial_state.nodes[2].AddState(ax::mojom::State::kIgnored);
1335
1336 initial_state.nodes[3].id = 4;
1337 initial_state.nodes[3].role = ax::mojom::Role::kStaticText;
1338
1339 AXTree tree(initial_state);
1340
1341 AXEventGenerator event_generator(&tree);
1342 AXTreeUpdate update = initial_state;
1343 update.nodes[0].AddState(ax::mojom::State::kIgnored);
1344 update.nodes[2].RemoveState(ax::mojom::State::kIgnored);
1345 update.nodes[3].AddState(ax::mojom::State::kIgnored);
1346 ASSERT_TRUE(tree.Unserialize(update));
1348 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 2));
1350 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 1));
1352 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 3));
1354 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 3));
1355}

◆ TEST() [62/215]

ui::TEST ( AXEventGeneratorTest  ,
IgnoredChangedFiredOnAncestorOnly4   
)

Definition at line 1357 of file ax_event_generator_unittest.cc.

1357 {
1358 // BEFORE
1359 // 1 (IGN)
1360 // |
1361 // 2
1362 // |
1363 // 3 (IGN)
1364 // |
1365 // 4 (IGN)
1366 // |
1367 // ____ 5 _____
1368 // / | \
1369 // 6 (IGN) 7 (IGN) 8
1370
1371 // AFTER
1372 // 1 (IGN)
1373 // |
1374 // 2
1375 // |
1376 // 3 (IGN)
1377 // |
1378 // 4 (IGN)
1379 // |
1380 // ____ 5 _____
1381 // / | \
1382 // 6 7 8 (IGN)
1383
1384 // IGNORED_CHANGED expected on #6, #7, #8
1385
1386 AXTreeUpdate initial_state;
1387 initial_state.root_id = 1;
1388 initial_state.nodes.resize(8);
1389 initial_state.nodes[0].id = 1;
1390 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
1391 initial_state.nodes[0].child_ids = {2};
1392
1393 initial_state.nodes[1].id = 2;
1394 initial_state.nodes[1].role = ax::mojom::Role::kGroup;
1395 initial_state.nodes[1].child_ids = {3};
1396
1397 initial_state.nodes[2].id = 3;
1398 initial_state.nodes[2].role = ax::mojom::Role::kGroup;
1399 initial_state.nodes[2].child_ids = {4};
1400 initial_state.nodes[2].AddState(ax::mojom::State::kIgnored);
1401
1402 initial_state.nodes[3].id = 4;
1403 initial_state.nodes[3].role = ax::mojom::Role::kGroup;
1404 initial_state.nodes[3].child_ids = {5};
1405 initial_state.nodes[3].AddState(ax::mojom::State::kIgnored);
1406
1407 initial_state.nodes[4].id = 5;
1408 initial_state.nodes[4].role = ax::mojom::Role::kGroup;
1409 initial_state.nodes[4].child_ids = {6, 7, 8};
1410
1411 initial_state.nodes[5].id = 6;
1412 initial_state.nodes[5].role = ax::mojom::Role::kStaticText;
1413 initial_state.nodes[5].AddState(ax::mojom::State::kIgnored);
1414
1415 initial_state.nodes[6].id = 7;
1416 initial_state.nodes[6].role = ax::mojom::Role::kStaticText;
1417 initial_state.nodes[6].AddState(ax::mojom::State::kIgnored);
1418
1419 initial_state.nodes[7].id = 8;
1420 initial_state.nodes[7].role = ax::mojom::Role::kStaticText;
1421
1422 AXTree tree(initial_state);
1423
1424 AXEventGenerator event_generator(&tree);
1425 AXTreeUpdate update = initial_state;
1426 update.nodes[5].RemoveState(ax::mojom::State::kIgnored);
1427 update.nodes[6].RemoveState(ax::mojom::State::kIgnored);
1428 update.nodes[7].AddState(ax::mojom::State::kIgnored);
1429 ASSERT_TRUE(tree.Unserialize(update));
1431 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 5));
1433 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 6));
1435 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 7));
1437 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 6));
1439 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 7));
1441 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 8));
1442}

◆ TEST() [63/215]

ui::TEST ( AXEventGeneratorTest  ,
IgnoredChangedFiredOnAncestorOnly5   
)

Definition at line 1444 of file ax_event_generator_unittest.cc.

1444 {
1445 // BEFORE
1446 // 1
1447 // |
1448 // 2
1449 // |
1450 // 3 (IGN)
1451 // |
1452 // 4 (IGN)
1453 // |
1454 // ____ 5 _____
1455 // / | \
1456 // 6 (IGN) 7 8
1457
1458 // AFTER
1459 // 1 (IGN)
1460 // |
1461 // 2
1462 // |
1463 // 3 (IGN)
1464 // |
1465 // 4 (IGN)
1466 // |
1467 // ____ 5 _____
1468 // / | \
1469 // 6 7 (IGN) 8 (IGN)
1470
1471 // IGNORED_CHANGED expected on #1, #6
1472
1473 AXTreeUpdate initial_state;
1474 initial_state.root_id = 1;
1475 initial_state.nodes.resize(8);
1476 initial_state.nodes[0].id = 1;
1477 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
1478 initial_state.nodes[0].child_ids = {2};
1479
1480 initial_state.nodes[1].id = 2;
1481 initial_state.nodes[1].role = ax::mojom::Role::kGroup;
1482 initial_state.nodes[1].child_ids = {3};
1483
1484 initial_state.nodes[2].id = 3;
1485 initial_state.nodes[2].role = ax::mojom::Role::kGroup;
1486 initial_state.nodes[2].child_ids = {4};
1487 initial_state.nodes[2].AddState(ax::mojom::State::kIgnored);
1488
1489 initial_state.nodes[3].id = 4;
1490 initial_state.nodes[3].role = ax::mojom::Role::kGroup;
1491 initial_state.nodes[3].child_ids = {5};
1492 initial_state.nodes[3].AddState(ax::mojom::State::kIgnored);
1493
1494 initial_state.nodes[4].id = 5;
1495 initial_state.nodes[4].role = ax::mojom::Role::kGroup;
1496 initial_state.nodes[4].child_ids = {6, 7, 8};
1497
1498 initial_state.nodes[5].id = 6;
1499 initial_state.nodes[5].role = ax::mojom::Role::kStaticText;
1500 initial_state.nodes[5].AddState(ax::mojom::State::kIgnored);
1501
1502 initial_state.nodes[6].id = 7;
1503 initial_state.nodes[6].role = ax::mojom::Role::kStaticText;
1504
1505 initial_state.nodes[7].id = 8;
1506 initial_state.nodes[7].role = ax::mojom::Role::kStaticText;
1507
1508 AXTree tree(initial_state);
1509
1510 AXEventGenerator event_generator(&tree);
1511 AXTreeUpdate update = initial_state;
1512 update.nodes[0].AddState(ax::mojom::State::kIgnored);
1513 update.nodes[5].RemoveState(ax::mojom::State::kIgnored);
1514 update.nodes[6].AddState(ax::mojom::State::kIgnored);
1515 update.nodes[7].AddState(ax::mojom::State::kIgnored);
1516 ASSERT_TRUE(tree.Unserialize(update));
1518 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 5));
1520 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 6));
1522 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 1));
1524 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 6));
1525}

◆ TEST() [64/215]

ui::TEST ( AXEventGeneratorTest  ,
IgnoredChangedFiredOnAncestorOnly6   
)

Definition at line 1527 of file ax_event_generator_unittest.cc.

1527 {
1528 // BEFORE
1529 // 1 (IGN)
1530 // |
1531 // 2
1532 // |
1533 // 3
1534 // |
1535 // 4
1536 // |
1537 // ____ 5 _____
1538 // / | \
1539 // 6 (IGN) 7 (IGN) 8
1540
1541 // AFTER
1542 // 1
1543 // |
1544 // 2
1545 // |
1546 // 3
1547 // |
1548 // 4
1549 // |
1550 // ____ 5 _____
1551 // / | \
1552 // 6 7 8 (IGN)
1553
1554 // IGNORED_CHANGED expected on #1, #8
1555
1556 AXTreeUpdate initial_state;
1557 initial_state.root_id = 1;
1558 initial_state.nodes.resize(8);
1559 initial_state.nodes[0].id = 1;
1560 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
1561 initial_state.nodes[0].child_ids = {2};
1562 initial_state.nodes[0].AddState(ax::mojom::State::kIgnored);
1563
1564 initial_state.nodes[1].id = 2;
1565 initial_state.nodes[1].role = ax::mojom::Role::kGroup;
1566 initial_state.nodes[1].child_ids = {3};
1567
1568 initial_state.nodes[2].id = 3;
1569 initial_state.nodes[2].role = ax::mojom::Role::kGroup;
1570 initial_state.nodes[2].child_ids = {4};
1571
1572 initial_state.nodes[3].id = 4;
1573 initial_state.nodes[3].role = ax::mojom::Role::kGroup;
1574 initial_state.nodes[3].child_ids = {5};
1575
1576 initial_state.nodes[4].id = 5;
1577 initial_state.nodes[4].role = ax::mojom::Role::kGroup;
1578 initial_state.nodes[4].child_ids = {6, 7, 8};
1579
1580 initial_state.nodes[5].id = 6;
1581 initial_state.nodes[5].role = ax::mojom::Role::kStaticText;
1582 initial_state.nodes[5].AddState(ax::mojom::State::kIgnored);
1583
1584 initial_state.nodes[6].id = 7;
1585 initial_state.nodes[6].role = ax::mojom::Role::kStaticText;
1586 initial_state.nodes[6].AddState(ax::mojom::State::kIgnored);
1587
1588 initial_state.nodes[7].id = 8;
1589 initial_state.nodes[7].role = ax::mojom::Role::kStaticText;
1590
1591 AXTree tree(initial_state);
1592
1593 AXEventGenerator event_generator(&tree);
1594 AXTreeUpdate update = initial_state;
1595 update.nodes[0].RemoveState(ax::mojom::State::kIgnored);
1596 update.nodes[5].RemoveState(ax::mojom::State::kIgnored);
1597 update.nodes[6].RemoveState(ax::mojom::State::kIgnored);
1598 update.nodes[7].AddState(ax::mojom::State::kIgnored);
1599 ASSERT_TRUE(tree.Unserialize(update));
1601 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 5));
1603 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 1));
1605 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 6));
1607 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 7));
1609 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 1));
1611 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 8));
1612}

◆ TEST() [65/215]

ui::TEST ( AXEventGeneratorTest  ,
IgnoredChangedFiredOnAncestorOnly7   
)

Definition at line 1614 of file ax_event_generator_unittest.cc.

1614 {
1615 // BEFORE
1616 // 1 (IGN)
1617 // |
1618 // 2 (IGN)
1619 // |
1620 // 3
1621 // |
1622 // __ 4 ___
1623 // / \
1624 // 5 (IGN) 6 (IGN)
1625
1626 // AFTER
1627 // 1
1628 // |
1629 // 2
1630 // |
1631 // 3 (IGN)
1632 // |
1633 // __ 4 (IGN)
1634 // / \
1635 // 5 (IGN) 6 (IGN)
1636
1637 // IGNORED_CHANGED expected on #1, #3
1638
1639 AXTreeUpdate initial_state;
1640 initial_state.root_id = 1;
1641 initial_state.nodes.resize(6);
1642 initial_state.nodes[0].id = 1;
1643 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
1644 initial_state.nodes[0].child_ids = {2};
1645 initial_state.nodes[0].AddState(ax::mojom::State::kIgnored);
1646
1647 initial_state.nodes[1].id = 2;
1648 initial_state.nodes[1].role = ax::mojom::Role::kGroup;
1649 initial_state.nodes[1].child_ids = {3};
1650 initial_state.nodes[1].AddState(ax::mojom::State::kIgnored);
1651
1652 initial_state.nodes[2].id = 3;
1653 initial_state.nodes[2].role = ax::mojom::Role::kGroup;
1654 initial_state.nodes[2].child_ids = {4};
1655
1656 initial_state.nodes[3].id = 4;
1657 initial_state.nodes[3].role = ax::mojom::Role::kGroup;
1658 initial_state.nodes[3].child_ids = {5, 6};
1659
1660 initial_state.nodes[4].id = 5;
1661 initial_state.nodes[4].role = ax::mojom::Role::kStaticText;
1662 initial_state.nodes[4].AddState(ax::mojom::State::kIgnored);
1663
1664 initial_state.nodes[5].id = 6;
1665 initial_state.nodes[5].role = ax::mojom::Role::kStaticText;
1666 initial_state.nodes[5].AddState(ax::mojom::State::kIgnored);
1667
1668 AXTree tree(initial_state);
1669
1670 AXEventGenerator event_generator(&tree);
1671 AXTreeUpdate update = initial_state;
1672 update.nodes[0].RemoveState(ax::mojom::State::kIgnored);
1673 update.nodes[1].RemoveState(ax::mojom::State::kIgnored);
1674 update.nodes[2].AddState(ax::mojom::State::kIgnored);
1675 update.nodes[3].AddState(ax::mojom::State::kIgnored);
1676 ASSERT_TRUE(tree.Unserialize(update));
1678 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 1));
1680 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 1));
1682 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 3));
1683}

◆ TEST() [66/215]

ui::TEST ( AXEventGeneratorTest  ,
IgnoredChangedFiredOnAncestorOnly8   
)

Definition at line 1685 of file ax_event_generator_unittest.cc.

1685 {
1686 // BEFORE
1687 // ____ 1 ____
1688 // | |
1689 // 2 (IGN) 7
1690 // |
1691 // 3 (IGN)
1692 // |
1693 // 4 (IGN)
1694 // |
1695 // 5 (IGN)
1696 // |
1697 // 6 (IGN)
1698
1699 // AFTER
1700 // ____ 1 ____
1701 // | |
1702 // 2 7 (IGN)
1703 // |
1704 // 3
1705 // |
1706 // 4
1707 // |
1708 // 5
1709 // |
1710 // 6
1711
1712 // IGNORED_CHANGED expected on #2, #7
1713
1714 AXTreeUpdate initial_state;
1715 initial_state.root_id = 1;
1716 initial_state.nodes.resize(7);
1717 initial_state.nodes[0].id = 1;
1718 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
1719 initial_state.nodes[0].child_ids = {2, 7};
1720
1721 initial_state.nodes[1].id = 2;
1722 initial_state.nodes[1].role = ax::mojom::Role::kGroup;
1723 initial_state.nodes[1].child_ids = {3};
1724 initial_state.nodes[1].AddState(ax::mojom::State::kIgnored);
1725
1726 initial_state.nodes[2].id = 3;
1727 initial_state.nodes[2].role = ax::mojom::Role::kGroup;
1728 initial_state.nodes[2].child_ids = {4};
1729 initial_state.nodes[2].AddState(ax::mojom::State::kIgnored);
1730
1731 initial_state.nodes[3].id = 4;
1732 initial_state.nodes[3].role = ax::mojom::Role::kGroup;
1733 initial_state.nodes[3].child_ids = {5};
1734 initial_state.nodes[3].AddState(ax::mojom::State::kIgnored);
1735
1736 initial_state.nodes[4].id = 5;
1737 initial_state.nodes[4].role = ax::mojom::Role::kGroup;
1738 initial_state.nodes[4].child_ids = {6};
1739 initial_state.nodes[4].AddState(ax::mojom::State::kIgnored);
1740
1741 initial_state.nodes[5].id = 5;
1742 initial_state.nodes[5].role = ax::mojom::Role::kStaticText;
1743 initial_state.nodes[5].AddState(ax::mojom::State::kIgnored);
1744
1745 initial_state.nodes[6].id = 7;
1746 initial_state.nodes[6].role = ax::mojom::Role::kStaticText;
1747
1748 AXTree tree(initial_state);
1749
1750 AXEventGenerator event_generator(&tree);
1751 AXTreeUpdate update = initial_state;
1752 update.nodes[1].RemoveState(ax::mojom::State::kIgnored);
1753 update.nodes[2].RemoveState(ax::mojom::State::kIgnored);
1754 update.nodes[3].RemoveState(ax::mojom::State::kIgnored);
1755 update.nodes[4].RemoveState(ax::mojom::State::kIgnored);
1756 update.nodes[5].RemoveState(ax::mojom::State::kIgnored);
1757 update.nodes[6].AddState(ax::mojom::State::kIgnored);
1758 ASSERT_TRUE(tree.Unserialize(update));
1760 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 1));
1762 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 2));
1764 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 2));
1766 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 7));
1767}

◆ TEST() [67/215]

ui::TEST ( AXEventGeneratorTest  ,
ImageAnnotationChanged   
)

Definition at line 1806 of file ax_event_generator_unittest.cc.

1806 {
1807 AXTreeUpdate initial_state;
1808 initial_state.root_id = 1;
1809 initial_state.nodes.resize(1);
1810 initial_state.nodes[0].id = 1;
1811 AXTree tree(initial_state);
1812
1813 AXEventGenerator event_generator(&tree);
1814 AXTreeUpdate update = initial_state;
1815 update.nodes[0].AddStringAttribute(
1817 ASSERT_TRUE(tree.Unserialize(update));
1818 EXPECT_TRUE(HasEvent(event_generator,
1819 AXEventGenerator::Event::IMAGE_ANNOTATION_CHANGED, 1));
1820}

◆ TEST() [68/215]

ui::TEST ( AXEventGeneratorTest  ,
ImageAnnotationStatusChanged   
)

Definition at line 1822 of file ax_event_generator_unittest.cc.

1822 {
1823 AXTreeUpdate initial_state;
1824 initial_state.root_id = 1;
1825 initial_state.nodes.resize(1);
1826 initial_state.nodes[0].id = 1;
1827 AXTree tree(initial_state);
1828
1829 AXEventGenerator event_generator(&tree);
1830 AXTreeUpdate update = initial_state;
1831 update.nodes[0].SetImageAnnotationStatus(
1833
1834 ASSERT_TRUE(tree.Unserialize(update));
1835 EXPECT_TRUE(HasEvent(event_generator,
1836 AXEventGenerator::Event::IMAGE_ANNOTATION_CHANGED, 1));
1837}

◆ TEST() [69/215]

ui::TEST ( AXEventGeneratorTest  ,
IntListPropertyChanges   
)

Definition at line 1925 of file ax_event_generator_unittest.cc.

1925 {
1926 AXTreeUpdate initial_state;
1927 initial_state.root_id = 1;
1928 initial_state.nodes.resize(1);
1929 initial_state.nodes[0].id = 1;
1930
1931 struct {
1933 std::vector<int> old_value;
1934 std::vector<int> new_value;
1935 } attributes[] = {
1939 };
1940 for (auto&& attrib : attributes) {
1941 initial_state.nodes.push_back({});
1942 initial_state.nodes.back().id = initial_state.nodes.size();
1943 initial_state.nodes.back().AddIntListAttribute(attrib.id, attrib.old_value);
1944 initial_state.nodes[0].child_ids.push_back(initial_state.nodes.size());
1945 }
1946
1947 AXTree tree(initial_state);
1948
1949 AXEventGenerator event_generator(&tree);
1950 int index = 1;
1951 for (auto&& attrib : attributes) {
1952 initial_state.nodes[index++].AddIntListAttribute(attrib.id,
1953 attrib.new_value);
1954 }
1955
1956 AXTreeUpdate update = initial_state;
1957 EXPECT_TRUE(tree.Unserialize(update));
1958 EXPECT_TRUE(HasEvent(event_generator,
1959 AXEventGenerator::Event::DESCRIBED_BY_CHANGED, 2));
1961 HasEvent(event_generator, AXEventGenerator::Event::FLOW_FROM_CHANGED, 1));
1963 HasEvent(event_generator, AXEventGenerator::Event::FLOW_FROM_CHANGED, 2));
1965 HasEvent(event_generator, AXEventGenerator::Event::FLOW_TO_CHANGED, 3));
1966 EXPECT_TRUE(HasEvent(event_generator,
1967 AXEventGenerator::Event::LABELED_BY_CHANGED, 4));
1968 EXPECT_TRUE(HasEvent(event_generator,
1969 AXEventGenerator::Event::RELATED_NODE_CHANGED, 2));
1970 EXPECT_TRUE(HasEvent(event_generator,
1971 AXEventGenerator::Event::RELATED_NODE_CHANGED, 3));
1972 EXPECT_TRUE(HasEvent(event_generator,
1973 AXEventGenerator::Event::RELATED_NODE_CHANGED, 4));
1974}
IntListAttribute
Definition: ax_enums.h:799
const uintptr_t id

◆ TEST() [70/215]

ui::TEST ( AXEventGeneratorTest  ,
IntPropertyChanges   
)

Definition at line 1886 of file ax_event_generator_unittest.cc.

1886 {
1887 AXTreeUpdate initial_state;
1888 initial_state.root_id = 1;
1889 initial_state.nodes.resize(1);
1890 initial_state.nodes[0].id = 1;
1891
1892 struct {
1894 int old_value;
1895 int new_value;
1896 } attributes[] = {
1900 };
1901 for (auto&& attrib : attributes) {
1902 initial_state.nodes.push_back({});
1903 initial_state.nodes.back().id = initial_state.nodes.size();
1904 initial_state.nodes.back().AddIntAttribute(attrib.id, attrib.old_value);
1905 initial_state.nodes[0].child_ids.push_back(initial_state.nodes.size());
1906 }
1907
1908 AXTree tree(initial_state);
1909
1910 AXEventGenerator event_generator(&tree);
1911 int index = 1;
1912 for (auto&& attrib : attributes)
1913 initial_state.nodes[index++].AddIntAttribute(attrib.id, attrib.new_value);
1914
1915 AXTreeUpdate update = initial_state;
1916 EXPECT_TRUE(tree.Unserialize(update));
1917 EXPECT_TRUE(HasEvent(event_generator,
1918 AXEventGenerator::Event::HIERARCHICAL_LEVEL_CHANGED, 2));
1919 EXPECT_TRUE(HasEvent(event_generator,
1920 AXEventGenerator::Event::POSITION_IN_SET_CHANGED, 3));
1922 HasEvent(event_generator, AXEventGenerator::Event::SET_SIZE_CHANGED, 4));
1923}

◆ TEST() [71/215]

ui::TEST ( AXEventGeneratorTest  ,
InvalidStatusChanged   
)

Definition at line 334 of file ax_event_generator_unittest.cc.

334 {
335 AXTreeUpdate initial_state;
336 initial_state.root_id = 1;
337 initial_state.nodes.resize(1);
338 initial_state.nodes[0].id = 1;
339 initial_state.nodes[0].role = ax::mojom::Role::kTextField;
340 initial_state.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kValue,
341 "Text");
342 AXTree tree(initial_state);
343
344 AXEventGenerator event_generator(&tree);
345 AXTreeUpdate update = initial_state;
346 update.nodes[0].SetInvalidState(ax::mojom::InvalidState::kTrue);
347 ASSERT_TRUE(tree.Unserialize(update));
348 EXPECT_TRUE(HasEvent(event_generator,
349 AXEventGenerator::Event::INVALID_STATUS_CHANGED, 1));
350}

◆ TEST() [72/215]

ui::TEST ( AXEventGeneratorTest  ,
LiveRegionChanged   
)

Definition at line 475 of file ax_event_generator_unittest.cc.

475 {
476 AXTreeUpdate initial_state;
477 initial_state.root_id = 1;
478 initial_state.nodes.resize(3);
479 initial_state.nodes[0].id = 1;
480 initial_state.nodes[0].AddStringAttribute(
482 initial_state.nodes[0].AddStringAttribute(
484 initial_state.nodes[0].child_ids.push_back(2);
485 initial_state.nodes[0].child_ids.push_back(3);
486 initial_state.nodes[1].id = 2;
487 initial_state.nodes[1].role = ax::mojom::Role::kStaticText;
488 initial_state.nodes[1].AddStringAttribute(
490 initial_state.nodes[1].AddStringAttribute(ax::mojom::StringAttribute::kName,
491 "Before 1");
492 initial_state.nodes[2].id = 3;
493 initial_state.nodes[2].role = ax::mojom::Role::kStaticText;
494 initial_state.nodes[2].AddStringAttribute(
496 initial_state.nodes[2].AddStringAttribute(ax::mojom::StringAttribute::kName,
497 "Before 2");
498 AXTree tree(initial_state);
499
500 AXEventGenerator event_generator(&tree);
501 AXTreeUpdate update = initial_state;
502 update.nodes[1].string_attributes.clear();
503 update.nodes[1].AddStringAttribute(
505 update.nodes[1].AddStringAttribute(ax::mojom::StringAttribute::kName,
506 "After 1");
507 update.nodes[2].string_attributes.clear();
508 update.nodes[2].AddStringAttribute(
510 update.nodes[2].AddStringAttribute(ax::mojom::StringAttribute::kName,
511 "After 2");
512
513 ASSERT_TRUE(tree.Unserialize(update));
514 EXPECT_TRUE(HasEvent(event_generator,
515 AXEventGenerator::Event::LIVE_REGION_CHANGED, 1));
516 EXPECT_TRUE(HasEvent(event_generator,
517 AXEventGenerator::Event::LIVE_REGION_NODE_CHANGED, 2));
518 EXPECT_TRUE(HasEvent(event_generator,
519 AXEventGenerator::Event::LIVE_REGION_NODE_CHANGED, 3));
521 HasEvent(event_generator, AXEventGenerator::Event::NAME_CHANGED, 2));
523 HasEvent(event_generator, AXEventGenerator::Event::NAME_CHANGED, 3));
524}

◆ TEST() [73/215]

ui::TEST ( AXEventGeneratorTest  ,
LiveRegionOnlyTextChanges   
)

Definition at line 526 of file ax_event_generator_unittest.cc.

526 {
527 AXTreeUpdate initial_state;
528 initial_state.root_id = 1;
529 initial_state.nodes.resize(3);
530 initial_state.nodes[0].id = 1;
531 initial_state.nodes[0].AddStringAttribute(
533 initial_state.nodes[0].AddStringAttribute(
535 initial_state.nodes[0].child_ids.push_back(2);
536 initial_state.nodes[0].child_ids.push_back(3);
537 initial_state.nodes[1].id = 2;
538 initial_state.nodes[1].role = ax::mojom::Role::kStaticText;
539 initial_state.nodes[1].AddStringAttribute(
541 initial_state.nodes[1].AddStringAttribute(ax::mojom::StringAttribute::kName,
542 "Before 1");
543 initial_state.nodes[2].id = 3;
544 initial_state.nodes[2].role = ax::mojom::Role::kStaticText;
545 initial_state.nodes[2].AddStringAttribute(
547 initial_state.nodes[2].AddStringAttribute(ax::mojom::StringAttribute::kName,
548 "Before 2");
549 AXTree tree(initial_state);
550
551 AXEventGenerator event_generator(&tree);
552 AXTreeUpdate update = initial_state;
553 update.nodes[1].AddStringAttribute(ax::mojom::StringAttribute::kDescription,
554 "Description 1");
555 update.nodes[2].SetCheckedState(ax::mojom::CheckedState::kTrue);
556
557 // Note that we do NOT expect a LIVE_REGION_CHANGED event here, because
558 // the name did not change.
559 ASSERT_TRUE(tree.Unserialize(update));
560 EXPECT_TRUE(HasEvent(event_generator,
561 AXEventGenerator::Event::CHECKED_STATE_CHANGED, 3));
562 EXPECT_TRUE(HasEvent(event_generator,
563 AXEventGenerator::Event::WIN_IACCESSIBLE_STATE_CHANGED,
564 3));
565 EXPECT_TRUE(HasEvent(event_generator,
566 AXEventGenerator::Event::DESCRIPTION_CHANGED, 2));
567}

◆ TEST() [74/215]

ui::TEST ( AXEventGeneratorTest  ,
LiveRelevantChanged   
)

Definition at line 2173 of file ax_event_generator_unittest.cc.

2173 {
2174 AXTreeUpdate initial_state;
2175 initial_state.root_id = 1;
2176 initial_state.nodes.resize(1);
2177 initial_state.nodes[0].id = 1;
2178
2179 AXTree tree(initial_state);
2180 AXEventGenerator event_generator(&tree);
2181 AXTreeUpdate update = initial_state;
2182
2183 update.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kLiveRelevant,
2184 "all");
2185 EXPECT_TRUE(tree.Unserialize(update));
2186 EXPECT_TRUE(HasEvent(event_generator,
2187 AXEventGenerator::Event::LIVE_RELEVANT_CHANGED, 1));
2188}

◆ TEST() [75/215]

ui::TEST ( AXEventGeneratorTest  ,
LoadCompleteNewTree   
)

Definition at line 48 of file ax_event_generator_unittest.cc.

48 {
49 AXTreeUpdate initial_state;
50 initial_state.root_id = 1;
51 initial_state.nodes.resize(1);
52 initial_state.nodes[0].id = 1;
53 initial_state.has_tree_data = true;
54 initial_state.tree_data.loaded = true;
55 AXTree tree(initial_state);
56
57 AXEventGenerator event_generator(&tree);
58 AXTreeUpdate load_complete_update;
59 load_complete_update.root_id = 2;
60 load_complete_update.nodes.resize(1);
61 load_complete_update.nodes[0].id = 2;
62 load_complete_update.nodes[0].relative_bounds.bounds =
63 gfx::RectF(0, 0, 800, 600);
64 load_complete_update.has_tree_data = true;
65 load_complete_update.tree_data.loaded = true;
66
67 ASSERT_TRUE(tree.Unserialize(load_complete_update));
69 HasEvent(event_generator, AXEventGenerator::Event::LOAD_COMPLETE, 2));
71 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 2));
72
73 // Load complete should not be emitted for sizeless roots.
74 load_complete_update.root_id = 3;
75 load_complete_update.nodes.resize(1);
76 load_complete_update.nodes[0].id = 3;
77 load_complete_update.nodes[0].relative_bounds.bounds = gfx::RectF(0, 0, 0, 0);
78 load_complete_update.has_tree_data = true;
79 load_complete_update.tree_data.loaded = true;
80
81 ASSERT_TRUE(tree.Unserialize(load_complete_update));
83 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 3));
84
85 // TODO(accessibility): http://crbug.com/888758
86 // Load complete should not be emitted for chrome-search URLs.
87 load_complete_update.root_id = 4;
88 load_complete_update.nodes.resize(1);
89 load_complete_update.nodes[0].id = 4;
90 load_complete_update.nodes[0].relative_bounds.bounds =
91 gfx::RectF(0, 0, 800, 600);
92 load_complete_update.nodes[0].AddStringAttribute(
93 ax::mojom::StringAttribute::kUrl, "chrome-search://foo");
94 load_complete_update.has_tree_data = true;
95 load_complete_update.tree_data.loaded = true;
96
97 ASSERT_TRUE(tree.Unserialize(load_complete_update));
99 HasEvent(event_generator, AXEventGenerator::Event::LOAD_COMPLETE, 4));
101 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 4));
102}

◆ TEST() [76/215]

ui::TEST ( AXEventGeneratorTest  ,
LoadCompleteSameTree   
)

Definition at line 30 of file ax_event_generator_unittest.cc.

30 {
31 AXTreeUpdate initial_state;
32 initial_state.root_id = 1;
33 initial_state.nodes.resize(1);
34 initial_state.nodes[0].id = 1;
35 initial_state.nodes[0].relative_bounds.bounds = gfx::RectF(0, 0, 800, 600);
36 initial_state.has_tree_data = true;
37 AXTree tree(initial_state);
38
39 AXEventGenerator event_generator(&tree);
40 AXTreeUpdate load_complete_update = initial_state;
41 load_complete_update.tree_data.loaded = true;
42
43 ASSERT_TRUE(tree.Unserialize(load_complete_update));
45 HasEvent(event_generator, AXEventGenerator::Event::LOAD_COMPLETE, 1));
46}

◆ TEST() [77/215]

ui::TEST ( AXEventGeneratorTest  ,
LoadStart   
)

Definition at line 104 of file ax_event_generator_unittest.cc.

104 {
105 AXTreeUpdate initial_state;
106 initial_state.root_id = 1;
107 initial_state.nodes.resize(1);
108 initial_state.nodes[0].id = 1;
109 initial_state.nodes[0].relative_bounds.bounds = gfx::RectF(0, 0, 800, 600);
110 initial_state.has_tree_data = true;
111 AXTree tree(initial_state);
112
113 AXEventGenerator event_generator(&tree);
114 AXTreeUpdate load_start_update;
115 load_start_update.root_id = 2;
116 load_start_update.nodes.resize(1);
117 load_start_update.nodes[0].id = 2;
118 load_start_update.nodes[0].relative_bounds.bounds =
119 gfx::RectF(0, 0, 800, 600);
120 load_start_update.has_tree_data = true;
121 load_start_update.tree_data.loaded = false;
122
123 ASSERT_TRUE(tree.Unserialize(load_start_update));
125 HasEvent(event_generator, AXEventGenerator::Event::LOAD_START, 2));
127 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 2));
128}

◆ TEST() [78/215]

ui::TEST ( AXEventGeneratorTest  ,
MenuItemSelected   
)

Definition at line 948 of file ax_event_generator_unittest.cc.

948 {
949 AXTreeUpdate initial_state;
950 initial_state.root_id = 1;
951 initial_state.nodes.resize(3);
952 initial_state.nodes[0].id = 1;
953 initial_state.nodes[0].role = ax::mojom::Role::kMenu;
954 initial_state.nodes[0].child_ids.push_back(2);
955 initial_state.nodes[0].child_ids.push_back(3);
956 initial_state.nodes[0].AddIntAttribute(
958 initial_state.nodes[1].id = 2;
959 initial_state.nodes[1].role = ax::mojom::Role::kMenuListOption;
960 initial_state.nodes[2].id = 3;
961 initial_state.nodes[2].role = ax::mojom::Role::kMenuListOption;
962 AXTree tree(initial_state);
963
964 AXEventGenerator event_generator(&tree);
965 AXTreeUpdate update = initial_state;
966 update.nodes[0].int_attributes.clear();
968 3);
969 ASSERT_TRUE(tree.Unserialize(update));
970 EXPECT_TRUE(HasEvent(event_generator,
971 AXEventGenerator::Event::ACTIVE_DESCENDANT_CHANGED, 1));
972 EXPECT_TRUE(HasEvent(event_generator,
973 AXEventGenerator::Event::MENU_ITEM_SELECTED, 3));
974 EXPECT_TRUE(HasEvent(event_generator,
975 AXEventGenerator::Event::RELATED_NODE_CHANGED, 1));
976}

◆ TEST() [79/215]

ui::TEST ( AXEventGeneratorTest  ,
MultilineStateChanged   
)

Definition at line 2190 of file ax_event_generator_unittest.cc.

2190 {
2191 AXTreeUpdate initial_state;
2192 initial_state.root_id = 1;
2193 initial_state.nodes.resize(1);
2194 initial_state.nodes[0].id = 1;
2195
2196 AXTree tree(initial_state);
2197 AXEventGenerator event_generator(&tree);
2198 AXTreeUpdate update = initial_state;
2199
2200 update.nodes[0].AddState(ax::mojom::State::kMultiline);
2201 EXPECT_TRUE(tree.Unserialize(update));
2202 EXPECT_TRUE(HasEvent(event_generator,
2203 AXEventGenerator::Event::MULTILINE_STATE_CHANGED, 1));
2205 HasEvent(event_generator, AXEventGenerator::Event::STATE_CHANGED, 1));
2206 EXPECT_TRUE(HasEvent(event_generator,
2207 AXEventGenerator::Event::WIN_IACCESSIBLE_STATE_CHANGED,
2208 1));
2209}

◆ TEST() [80/215]

ui::TEST ( AXEventGeneratorTest  ,
MultiselectableStateChanged   
)

Definition at line 1999 of file ax_event_generator_unittest.cc.

1999 {
2000 AXTreeUpdate initial_state;
2001 initial_state.root_id = 1;
2002 initial_state.nodes.resize(1);
2003 initial_state.nodes[0].id = 1;
2004 initial_state.nodes[0].role = ax::mojom::Role::kGrid;
2005
2006 AXTree tree(initial_state);
2007 AXEventGenerator event_generator(&tree);
2008 AXTreeUpdate update = initial_state;
2009
2010 update.nodes[0].AddState(ax::mojom::State::kMultiselectable);
2011 EXPECT_TRUE(tree.Unserialize(update));
2012 EXPECT_TRUE(HasEvent(event_generator,
2013 AXEventGenerator::Event::MULTISELECTABLE_STATE_CHANGED,
2014 1));
2016 HasEvent(event_generator, AXEventGenerator::Event::STATE_CHANGED, 1));
2017 EXPECT_TRUE(HasEvent(event_generator,
2018 AXEventGenerator::Event::WIN_IACCESSIBLE_STATE_CHANGED,
2019 1));
2020}

◆ TEST() [81/215]

ui::TEST ( AXEventGeneratorTest  ,
NameChanged   
)

Definition at line 899 of file ax_event_generator_unittest.cc.

899 {
900 AXTreeUpdate initial_state;
901 initial_state.root_id = 1;
902 initial_state.nodes.resize(2);
903 initial_state.nodes[0].id = 1;
904 initial_state.nodes[0].child_ids.push_back(2);
905 initial_state.nodes[1].id = 2;
906 AXTree tree(initial_state);
907
908 AXEventGenerator event_generator(&tree);
909 AXTreeUpdate update = initial_state;
910 update.nodes[1].AddStringAttribute(ax::mojom::StringAttribute::kName,
911 "Hello");
912 ASSERT_TRUE(tree.Unserialize(update));
914 HasEvent(event_generator, AXEventGenerator::Event::NAME_CHANGED, 2));
915}

◆ TEST() [82/215]

ui::TEST ( AXEventGeneratorTest  ,
NodeBecomesIgnored   
)

Definition at line 978 of file ax_event_generator_unittest.cc.

978 {
979 AXTreeUpdate initial_state;
980 initial_state.root_id = 1;
981 initial_state.nodes.resize(5);
982 initial_state.nodes[0].id = 1;
983 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
984 initial_state.nodes[0].child_ids.push_back(2);
985 initial_state.nodes[1].id = 2;
986 initial_state.nodes[1].role = ax::mojom::Role::kArticle;
987 initial_state.nodes[1].child_ids.push_back(3);
988 initial_state.nodes[2].id = 3;
989 initial_state.nodes[2].role = ax::mojom::Role::kGroup;
990 initial_state.nodes[2].AddState(ax::mojom::State::kIgnored);
991 initial_state.nodes[2].child_ids.push_back(4);
992 initial_state.nodes[3].id = 4;
993 initial_state.nodes[3].role = ax::mojom::Role::kGroup;
994 initial_state.nodes[3].child_ids.push_back(5);
995 initial_state.nodes[4].id = 5;
996 initial_state.nodes[4].role = ax::mojom::Role::kStaticText;
997
998 AXTree tree(initial_state);
999
1000 AXEventGenerator event_generator(&tree);
1001 AXTreeUpdate update = initial_state;
1002 update.nodes[3].AddState(ax::mojom::State::kIgnored);
1003 ASSERT_TRUE(tree.Unserialize(update));
1005 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 2));
1007 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 4));
1008}

◆ TEST() [83/215]

ui::TEST ( AXEventGeneratorTest  ,
NodeBecomesIgnored2   
)

Definition at line 1010 of file ax_event_generator_unittest.cc.

1010 {
1011 AXTreeUpdate initial_state;
1012 initial_state.root_id = 1;
1013 initial_state.nodes.resize(5);
1014 initial_state.nodes[0].id = 1;
1015 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
1016 initial_state.nodes[0].child_ids.push_back(2);
1017 initial_state.nodes[1].id = 2;
1018 initial_state.nodes[1].role = ax::mojom::Role::kArticle;
1019 initial_state.nodes[1].child_ids.push_back(3);
1020 initial_state.nodes[2].id = 3;
1021 initial_state.nodes[2].role = ax::mojom::Role::kGroup;
1022 initial_state.nodes[2].AddState(ax::mojom::State::kIgnored);
1023 initial_state.nodes[2].child_ids.push_back(4);
1024 initial_state.nodes[3].id = 4;
1025 initial_state.nodes[3].role = ax::mojom::Role::kGroup;
1026 initial_state.nodes[3].child_ids.push_back(5);
1027 initial_state.nodes[4].id = 5;
1028 initial_state.nodes[4].role = ax::mojom::Role::kStaticText;
1029
1030 AXTree tree(initial_state);
1031
1032 AXEventGenerator event_generator(&tree);
1033 AXTreeUpdate update = initial_state;
1034 // Marking as ignored should fire CHILDREN_CHANGED on 2
1035 update.nodes[3].AddState(ax::mojom::State::kIgnored);
1036 // Remove node id 5 so it also fires CHILDREN_CHANGED on 4.
1037 update.nodes.pop_back();
1038 update.nodes[3].child_ids.clear();
1039 ASSERT_TRUE(tree.Unserialize(update));
1041 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 2));
1043 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 4));
1044}

◆ TEST() [84/215]

ui::TEST ( AXEventGeneratorTest  ,
NodeBecomesUnignored   
)

Definition at line 1046 of file ax_event_generator_unittest.cc.

1046 {
1047 AXTreeUpdate initial_state;
1048 initial_state.root_id = 1;
1049 initial_state.nodes.resize(5);
1050 initial_state.nodes[0].id = 1;
1051 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
1052 initial_state.nodes[0].child_ids.push_back(2);
1053 initial_state.nodes[1].id = 2;
1054 initial_state.nodes[1].role = ax::mojom::Role::kArticle;
1055 initial_state.nodes[1].child_ids.push_back(3);
1056 initial_state.nodes[2].id = 3;
1057 initial_state.nodes[2].role = ax::mojom::Role::kGroup;
1058 initial_state.nodes[2].AddState(ax::mojom::State::kIgnored);
1059 initial_state.nodes[2].child_ids.push_back(4);
1060 initial_state.nodes[3].id = 4;
1061 initial_state.nodes[3].role = ax::mojom::Role::kGroup;
1062 initial_state.nodes[3].AddState(ax::mojom::State::kIgnored);
1063 initial_state.nodes[3].child_ids.push_back(5);
1064 initial_state.nodes[4].id = 5;
1065 initial_state.nodes[4].role = ax::mojom::Role::kStaticText;
1066
1067 AXTree tree(initial_state);
1068
1069 AXEventGenerator event_generator(&tree);
1070 AXTreeUpdate update = initial_state;
1071 update.nodes[3].state = 0;
1072 ASSERT_TRUE(tree.Unserialize(update));
1074 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 2));
1076 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 4));
1078 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 4));
1079}

◆ TEST() [85/215]

ui::TEST ( AXEventGeneratorTest  ,
NodeBecomesUnignored2   
)

Definition at line 1081 of file ax_event_generator_unittest.cc.

1081 {
1082 AXTreeUpdate initial_state;
1083 initial_state.root_id = 1;
1084 initial_state.nodes.resize(5);
1085 initial_state.nodes[0].id = 1;
1086 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
1087 initial_state.nodes[0].child_ids.push_back(2);
1088 initial_state.nodes[1].id = 2;
1089 initial_state.nodes[1].role = ax::mojom::Role::kArticle;
1090 initial_state.nodes[1].child_ids.push_back(3);
1091 initial_state.nodes[2].id = 3;
1092 initial_state.nodes[2].role = ax::mojom::Role::kGroup;
1093 initial_state.nodes[2].AddState(ax::mojom::State::kIgnored);
1094 initial_state.nodes[2].child_ids.push_back(4);
1095 initial_state.nodes[3].id = 4;
1096 initial_state.nodes[3].role = ax::mojom::Role::kGroup;
1097 initial_state.nodes[3].AddState(ax::mojom::State::kIgnored);
1098 initial_state.nodes[3].child_ids.push_back(5);
1099 initial_state.nodes[4].id = 5;
1100 initial_state.nodes[4].role = ax::mojom::Role::kStaticText;
1101
1102 AXTree tree(initial_state);
1103
1104 AXEventGenerator event_generator(&tree);
1105 AXTreeUpdate update = initial_state;
1106 // Marking as no longer ignored should fire CHILDREN_CHANGED on 2
1107 update.nodes[3].state = 0;
1108 // Remove node id 5 so it also fires CHILDREN_CHANGED on 4.
1109 update.nodes.pop_back();
1110 update.nodes[3].child_ids.clear();
1111 ASSERT_TRUE(tree.Unserialize(update));
1113 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 2));
1115 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 4));
1117 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 4));
1118}

◆ TEST() [86/215]

ui::TEST ( AXEventGeneratorTest  ,
ObjectAttributeChanged   
)

Definition at line 827 of file ax_event_generator_unittest.cc.

827 {
828 AXTreeUpdate initial_state;
829 initial_state.root_id = 1;
830 initial_state.nodes.resize(3);
831 initial_state.nodes[0].id = 1;
832 initial_state.nodes[0].child_ids = {2, 3};
833 initial_state.nodes[1].id = 2;
834 initial_state.nodes[2].id = 3;
835 AXTree tree(initial_state);
836
837 AXEventGenerator event_generator(&tree);
838 AXTreeUpdate update = initial_state;
839 update.nodes[1].AddIntAttribute(ax::mojom::IntAttribute::kTextAlign, 2);
840 update.nodes[2].AddFloatAttribute(ax::mojom::FloatAttribute::kTextIndent,
841 10.0f);
842 ASSERT_TRUE(tree.Unserialize(update));
844 HasEvent(event_generator,
845 AXEventGenerator::Event::ATK_TEXT_OBJECT_ATTRIBUTE_CHANGED, 2));
847 HasEvent(event_generator,
848 AXEventGenerator::Event::ATK_TEXT_OBJECT_ATTRIBUTE_CHANGED, 3));
849 EXPECT_TRUE(HasEvent(event_generator,
850 AXEventGenerator::Event::OBJECT_ATTRIBUTE_CHANGED, 2));
851 EXPECT_TRUE(HasEvent(event_generator,
852 AXEventGenerator::Event::OBJECT_ATTRIBUTE_CHANGED, 3));
853}

◆ TEST() [87/215]

ui::TEST ( AXEventGeneratorTest  ,
OtherAttributeChanged   
)

Definition at line 855 of file ax_event_generator_unittest.cc.

855 {
856 AXTreeUpdate initial_state;
857 initial_state.root_id = 1;
858 initial_state.nodes.resize(6);
859 initial_state.nodes[0].id = 1;
860 initial_state.nodes[0].child_ids.push_back(2);
861 initial_state.nodes[0].child_ids.push_back(3);
862 initial_state.nodes[0].child_ids.push_back(4);
863 initial_state.nodes[0].child_ids.push_back(5);
864 initial_state.nodes[0].child_ids.push_back(6);
865 initial_state.nodes[1].id = 2;
866 initial_state.nodes[2].id = 3;
867 initial_state.nodes[3].id = 4;
868 initial_state.nodes[4].id = 5;
869 initial_state.nodes[5].id = 6;
870 AXTree tree(initial_state);
871
872 AXEventGenerator event_generator(&tree);
873 AXTreeUpdate update = initial_state;
874 update.nodes[1].AddStringAttribute(ax::mojom::StringAttribute::kLanguage,
875 "de");
877 7);
878 update.nodes[3].AddFloatAttribute(ax::mojom::FloatAttribute::kFontSize,
879 12.0f);
880 update.nodes[4].AddBoolAttribute(ax::mojom::BoolAttribute::kModal, true);
881 std::vector<int> ids = {2};
882 update.nodes[5].AddIntListAttribute(ax::mojom::IntListAttribute::kControlsIds,
883 ids);
884 ASSERT_TRUE(tree.Unserialize(update));
886 HasEvent(event_generator, AXEventGenerator::Event::CONTROLS_CHANGED, 6));
888 HasEvent(event_generator, AXEventGenerator::Event::LANGUAGE_CHANGED, 2));
889 EXPECT_TRUE(HasEvent(event_generator,
890 AXEventGenerator::Event::OTHER_ATTRIBUTE_CHANGED, 3));
891 EXPECT_TRUE(HasEvent(event_generator,
892 AXEventGenerator::Event::TEXT_ATTRIBUTE_CHANGED, 4));
893 EXPECT_TRUE(HasEvent(event_generator,
894 AXEventGenerator::Event::OTHER_ATTRIBUTE_CHANGED, 5));
895 EXPECT_TRUE(HasEvent(event_generator,
896 AXEventGenerator::Event::RELATED_NODE_CHANGED, 6));
897}

◆ TEST() [88/215]

ui::TEST ( AXEventGeneratorTest  ,
RemoveChild   
)

Definition at line 638 of file ax_event_generator_unittest.cc.

638 {
639 AXTreeUpdate initial_state;
640 initial_state.root_id = 1;
641 initial_state.nodes.resize(3);
642 initial_state.nodes[0].id = 1;
643 initial_state.nodes[0].child_ids.push_back(2);
644 initial_state.nodes[0].child_ids.push_back(3);
645 initial_state.nodes[1].id = 2;
646 initial_state.nodes[2].id = 3;
647 AXTree tree(initial_state);
648
649 AXEventGenerator event_generator(&tree);
650 AXTreeUpdate update = initial_state;
651 update.nodes.resize(2);
652 update.nodes[0].child_ids.clear();
653 update.nodes[0].child_ids.push_back(2);
654
655 ASSERT_TRUE(tree.Unserialize(update));
657 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 1));
658}

◆ TEST() [89/215]

ui::TEST ( AXEventGeneratorTest  ,
ReorderChildren   
)

Definition at line 660 of file ax_event_generator_unittest.cc.

660 {
661 AXTreeUpdate initial_state;
662 initial_state.root_id = 1;
663 initial_state.nodes.resize(3);
664 initial_state.nodes[0].id = 1;
665 initial_state.nodes[0].child_ids.push_back(2);
666 initial_state.nodes[0].child_ids.push_back(3);
667 initial_state.nodes[1].id = 2;
668 initial_state.nodes[2].id = 3;
669 AXTree tree(initial_state);
670
671 AXEventGenerator event_generator(&tree);
672 AXTreeUpdate update = initial_state;
673 update.nodes[0].child_ids.clear();
674 update.nodes[0].child_ids.push_back(3);
675 update.nodes[0].child_ids.push_back(2);
676
677 ASSERT_TRUE(tree.Unserialize(update));
679 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 1));
680}

◆ TEST() [90/215]

ui::TEST ( AXEventGeneratorTest  ,
RequiredStateChanged   
)

Definition at line 2022 of file ax_event_generator_unittest.cc.

2022 {
2023 AXTreeUpdate initial_state;
2024 initial_state.root_id = 1;
2025 initial_state.nodes.resize(1);
2026 initial_state.nodes[0].id = 1;
2027 initial_state.nodes[0].role = ax::mojom::Role::kTextField;
2028
2029 AXTree tree(initial_state);
2030 AXEventGenerator event_generator(&tree);
2031 AXTreeUpdate update = initial_state;
2032
2033 update.nodes[0].AddState(ax::mojom::State::kRequired);
2034 EXPECT_TRUE(tree.Unserialize(update));
2035 EXPECT_TRUE(HasEvent(event_generator,
2036 AXEventGenerator::Event::REQUIRED_STATE_CHANGED, 1));
2038 HasEvent(event_generator, AXEventGenerator::Event::STATE_CHANGED, 1));
2039 EXPECT_TRUE(HasEvent(event_generator,
2040 AXEventGenerator::Event::WIN_IACCESSIBLE_STATE_CHANGED,
2041 1));
2042}

◆ TEST() [91/215]

ui::TEST ( AXEventGeneratorTest  ,
RoleChanged   
)

Definition at line 933 of file ax_event_generator_unittest.cc.

933 {
934 AXTreeUpdate initial_state;
935 initial_state.root_id = 1;
936 initial_state.nodes.resize(1);
937 initial_state.nodes[0].id = 1;
938 AXTree tree(initial_state);
939
940 AXEventGenerator event_generator(&tree);
941 AXTreeUpdate update = initial_state;
942 update.nodes[0].role = ax::mojom::Role::kCheckBox;
943 ASSERT_TRUE(tree.Unserialize(update));
945 HasEvent(event_generator, AXEventGenerator::Event::ROLE_CHANGED, 1));
946}

◆ TEST() [92/215]

ui::TEST ( AXEventGeneratorTest  ,
ScrollHorizontalPositionChanged   
)

Definition at line 682 of file ax_event_generator_unittest.cc.

682 {
683 AXTreeUpdate initial_state;
684 initial_state.root_id = 1;
685 initial_state.nodes.resize(1);
686 initial_state.nodes[0].id = 1;
687 AXTree tree(initial_state);
688
689 AXEventGenerator event_generator(&tree);
690 AXTreeUpdate update = initial_state;
691 update.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kScrollX, 10);
692 EXPECT_TRUE(tree.Unserialize(update));
694 HasEvent(event_generator,
695 AXEventGenerator::Event::SCROLL_HORIZONTAL_POSITION_CHANGED, 1));
696}

◆ TEST() [93/215]

ui::TEST ( AXEventGeneratorTest  ,
ScrollVerticalPositionChanged   
)

Definition at line 698 of file ax_event_generator_unittest.cc.

698 {
699 AXTreeUpdate initial_state;
700 initial_state.root_id = 1;
701 initial_state.nodes.resize(1);
702 initial_state.nodes[0].id = 1;
703 AXTree tree(initial_state);
704
705 AXEventGenerator event_generator(&tree);
706 AXTreeUpdate update = initial_state;
707 update.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kScrollY, 10);
708 ASSERT_TRUE(tree.Unserialize(update));
710 HasEvent(event_generator,
711 AXEventGenerator::Event::SCROLL_VERTICAL_POSITION_CHANGED, 1));
712}

◆ TEST() [94/215]

ui::TEST ( AXEventGeneratorTest  ,
SelectedAndSelectedChildren   
)

Definition at line 249 of file ax_event_generator_unittest.cc.

249 {
250 AXTreeUpdate initial_state;
251 initial_state.root_id = 1;
252 initial_state.nodes.resize(4);
253 initial_state.nodes[0].id = 1;
254 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
255 initial_state.nodes[0].child_ids.push_back(2);
256 initial_state.nodes[0].child_ids.push_back(4);
257 initial_state.nodes[1].id = 2;
258 initial_state.nodes[1].role = ax::mojom::Role::kMenu;
259 initial_state.nodes[1].child_ids.push_back(3);
260 initial_state.nodes[2].id = 3;
261 initial_state.nodes[2].role = ax::mojom::Role::kMenuItem;
262 initial_state.nodes[3].id = 4;
263 initial_state.nodes[3].role = ax::mojom::Role::kListBoxOption;
264 initial_state.nodes[3].AddBoolAttribute(ax::mojom::BoolAttribute::kSelected,
265 true);
266 AXTree tree(initial_state);
267
268 AXEventGenerator event_generator(&tree);
269 AXTreeUpdate update = initial_state;
270 update.nodes[2].AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, true);
271 update.nodes.pop_back();
272 update.nodes.emplace_back();
273 update.nodes[3].id = 4;
275 update.nodes[3].AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, false);
276
277 ASSERT_TRUE(tree.Unserialize(update));
278 EXPECT_TRUE(HasEvent(event_generator,
279 AXEventGenerator::Event::SELECTED_CHILDREN_CHANGED, 2));
281 HasEvent(event_generator, AXEventGenerator::Event::SELECTED_CHANGED, 3));
282 EXPECT_TRUE(HasEvent(event_generator,
283 AXEventGenerator::Event::WIN_IACCESSIBLE_STATE_CHANGED,
284 3));
286 HasEvent(event_generator, AXEventGenerator::Event::SELECTED_CHANGED, 4));
287 EXPECT_TRUE(HasEvent(event_generator,
288 AXEventGenerator::Event::WIN_IACCESSIBLE_STATE_CHANGED,
289 4));
290}

◆ TEST() [95/215]

ui::TEST ( AXEventGeneratorTest  ,
StringPropertyChanges   
)

Definition at line 1839 of file ax_event_generator_unittest.cc.

1839 {
1840 AXTreeUpdate initial_state;
1841 initial_state.root_id = 1;
1842 initial_state.nodes.resize(1);
1843 initial_state.nodes[0].id = 1;
1844
1845 struct {
1847 std::string old_value;
1848 std::string new_value;
1849 } attributes[] = {
1855 };
1856 for (auto&& attrib : attributes) {
1857 initial_state.nodes.push_back({});
1858 initial_state.nodes.back().id = initial_state.nodes.size();
1859 initial_state.nodes.back().AddStringAttribute(attrib.id, attrib.old_value);
1860 initial_state.nodes[0].child_ids.push_back(initial_state.nodes.size());
1861 }
1862
1863 AXTree tree(initial_state);
1864
1865 AXEventGenerator event_generator(&tree);
1866 int index = 1;
1867 for (auto&& attrib : attributes) {
1868 initial_state.nodes[index++].AddStringAttribute(attrib.id,
1869 attrib.new_value);
1870 }
1871
1872 AXTreeUpdate update = initial_state;
1873 EXPECT_TRUE(tree.Unserialize(update));
1874 EXPECT_TRUE(HasEvent(event_generator,
1875 AXEventGenerator::Event::ACCESS_KEY_CHANGED, 2));
1876 EXPECT_TRUE(HasEvent(event_generator,
1877 AXEventGenerator::Event::CLASS_NAME_CHANGED, 3));
1878 EXPECT_TRUE(HasEvent(event_generator,
1879 AXEventGenerator::Event::KEY_SHORTCUTS_CHANGED, 4));
1881 HasEvent(event_generator, AXEventGenerator::Event::LANGUAGE_CHANGED, 5));
1882 EXPECT_TRUE(HasEvent(event_generator,
1883 AXEventGenerator::Event::PLACEHOLDER_CHANGED, 6));
1884}
StringAttribute
Definition: ax_enums.h:521

◆ TEST() [96/215]

ui::TEST ( AXEventGeneratorTest  ,
StringValueChanged   
)

Definition at line 292 of file ax_event_generator_unittest.cc.

292 {
293 AXTreeUpdate initial_state;
294 initial_state.root_id = 1;
295 initial_state.nodes.resize(1);
296 initial_state.nodes[0].id = 1;
297 initial_state.nodes[0].role = ax::mojom::Role::kTextField;
298 initial_state.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kValue,
299 "Before");
300 AXTree tree(initial_state);
301
302 AXEventGenerator event_generator(&tree);
303 AXTreeUpdate update = initial_state;
304 update.nodes[0].string_attributes.clear();
305 update.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kValue,
306 "After");
307
308 ASSERT_TRUE(tree.Unserialize(update));
310 HasEvent(event_generator, AXEventGenerator::Event::VALUE_CHANGED, 1));
311}

◆ TEST() [97/215]

ui::TEST ( AXEventGeneratorTest  ,
SubtreeBecomesUnignored   
)

Definition at line 1120 of file ax_event_generator_unittest.cc.

1120 {
1121 AXTreeUpdate initial_state;
1122 initial_state.root_id = 1;
1123 initial_state.nodes.resize(3);
1124 initial_state.nodes[0].id = 1;
1125 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
1126 initial_state.nodes[0].child_ids.push_back(2);
1127 initial_state.nodes[1].id = 2;
1128 initial_state.nodes[1].role = ax::mojom::Role::kArticle;
1129 initial_state.nodes[1].AddState(ax::mojom::State::kIgnored);
1130 initial_state.nodes[1].child_ids.push_back(3);
1131 initial_state.nodes[2].id = 3;
1132 initial_state.nodes[2].role = ax::mojom::Role::kGroup;
1133 initial_state.nodes[2].AddState(ax::mojom::State::kIgnored);
1134
1135 AXTree tree(initial_state);
1136
1137 AXEventGenerator event_generator(&tree);
1138 AXTreeUpdate update = initial_state;
1139 update.nodes[1].RemoveState(ax::mojom::State::kIgnored);
1140 update.nodes[2].RemoveState(ax::mojom::State::kIgnored);
1141 ASSERT_TRUE(tree.Unserialize(update));
1143 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 1));
1145 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 2));
1147 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 2));
1148}

◆ TEST() [98/215]

ui::TEST ( AXEventGeneratorTest  ,
TextAttributeChanged   
)

Definition at line 714 of file ax_event_generator_unittest.cc.

714 {
715 AXTreeUpdate initial_state;
716 initial_state.root_id = 1;
717 initial_state.nodes.resize(17);
718 initial_state.nodes[0].id = 1;
719 initial_state.nodes[0].child_ids = {2, 3, 4, 5, 6, 7, 8, 9,
720 10, 11, 12, 13, 14, 15, 16, 17};
721 initial_state.nodes[1].id = 2;
722 initial_state.nodes[2].id = 3;
723 initial_state.nodes[3].id = 4;
724 initial_state.nodes[4].id = 5;
725 initial_state.nodes[5].id = 6;
726 initial_state.nodes[6].id = 7;
727 initial_state.nodes[7].id = 8;
728 initial_state.nodes[8].id = 9;
729 initial_state.nodes[9].id = 10;
730 initial_state.nodes[10].id = 11;
731 initial_state.nodes[11].id = 12;
732 initial_state.nodes[12].id = 13;
733 initial_state.nodes[13].id = 14;
734 initial_state.nodes[14].id = 15;
735 initial_state.nodes[15].id = 16;
736 initial_state.nodes[16].id = 17;
737
738 // To test changing the start and end of existing markers.
739 initial_state.nodes[11].AddIntListAttribute(
741 {static_cast<int32_t>(ax::mojom::MarkerType::kTextMatch)});
742 initial_state.nodes[11].AddIntListAttribute(
744 initial_state.nodes[11].AddIntListAttribute(
746
747 AXTree tree(initial_state);
748
749 AXEventGenerator event_generator(&tree);
750 AXTreeUpdate update = initial_state;
751 update.nodes[1].AddIntAttribute(ax::mojom::IntAttribute::kColor, 0);
752 update.nodes[2].AddIntAttribute(ax::mojom::IntAttribute::kBackgroundColor, 0);
753 update.nodes[3].AddIntAttribute(
755 static_cast<int32_t>(ax::mojom::WritingDirection::kRtl));
756 update.nodes[4].AddIntAttribute(
758 static_cast<int32_t>(ax::mojom::TextPosition::kSuperscript));
759 update.nodes[5].AddIntAttribute(
761 static_cast<int32_t>(ax::mojom::TextStyle::kBold));
762 update.nodes[6].AddIntAttribute(
764 static_cast<int32_t>(ax::mojom::TextDecorationStyle::kSolid));
765 update.nodes[7].AddIntAttribute(
767 static_cast<int32_t>(ax::mojom::TextDecorationStyle::kWavy));
768 update.nodes[8].AddIntAttribute(
770 static_cast<int32_t>(ax::mojom::TextDecorationStyle::kDotted));
771 update.nodes[9].AddIntListAttribute(
773 {static_cast<int32_t>(ax::mojom::MarkerType::kSpelling)});
774 update.nodes[10].AddIntListAttribute(
776 {static_cast<int32_t>(ax::mojom::MarkerType::kGrammar)});
777 update.nodes[11].AddIntListAttribute(ax::mojom::IntListAttribute::kMarkerEnds,
778 {11});
779 update.nodes[12].AddIntListAttribute(
781 {static_cast<int32_t>(ax::mojom::MarkerType::kActiveSuggestion)});
782 update.nodes[13].AddIntListAttribute(
784 {static_cast<int32_t>(ax::mojom::MarkerType::kSuggestion)});
785 update.nodes[14].AddFloatAttribute(ax::mojom::FloatAttribute::kFontSize,
786 12.0f);
787 update.nodes[15].AddFloatAttribute(ax::mojom::FloatAttribute::kFontWeight,
788 600.0f);
789 update.nodes[16].AddStringAttribute(ax::mojom::StringAttribute::kFontFamily,
790 "sans");
791
792 ASSERT_TRUE(tree.Unserialize(update));
793 EXPECT_TRUE(HasEvent(event_generator,
794 AXEventGenerator::Event::TEXT_ATTRIBUTE_CHANGED, 2));
795 EXPECT_TRUE(HasEvent(event_generator,
796 AXEventGenerator::Event::TEXT_ATTRIBUTE_CHANGED, 3));
797 EXPECT_TRUE(HasEvent(event_generator,
798 AXEventGenerator::Event::TEXT_ATTRIBUTE_CHANGED, 4));
799 EXPECT_TRUE(HasEvent(event_generator,
800 AXEventGenerator::Event::TEXT_ATTRIBUTE_CHANGED, 5));
801 EXPECT_TRUE(HasEvent(event_generator,
802 AXEventGenerator::Event::TEXT_ATTRIBUTE_CHANGED, 6));
803 EXPECT_TRUE(HasEvent(event_generator,
804 AXEventGenerator::Event::TEXT_ATTRIBUTE_CHANGED, 7));
805 EXPECT_TRUE(HasEvent(event_generator,
806 AXEventGenerator::Event::TEXT_ATTRIBUTE_CHANGED, 8));
807 EXPECT_TRUE(HasEvent(event_generator,
808 AXEventGenerator::Event::TEXT_ATTRIBUTE_CHANGED, 9));
809 EXPECT_TRUE(HasEvent(event_generator,
810 AXEventGenerator::Event::TEXT_ATTRIBUTE_CHANGED, 10));
811 EXPECT_TRUE(HasEvent(event_generator,
812 AXEventGenerator::Event::TEXT_ATTRIBUTE_CHANGED, 11));
813 EXPECT_TRUE(HasEvent(event_generator,
814 AXEventGenerator::Event::TEXT_ATTRIBUTE_CHANGED, 12));
815 EXPECT_TRUE(HasEvent(event_generator,
816 AXEventGenerator::Event::TEXT_ATTRIBUTE_CHANGED, 13));
817 EXPECT_TRUE(HasEvent(event_generator,
818 AXEventGenerator::Event::TEXT_ATTRIBUTE_CHANGED, 14));
819 EXPECT_TRUE(HasEvent(event_generator,
820 AXEventGenerator::Event::TEXT_ATTRIBUTE_CHANGED, 15));
821 EXPECT_TRUE(HasEvent(event_generator,
822 AXEventGenerator::Event::TEXT_ATTRIBUTE_CHANGED, 16));
823 EXPECT_TRUE(HasEvent(event_generator,
824 AXEventGenerator::Event::TEXT_ATTRIBUTE_CHANGED, 17));
825}

◆ TEST() [99/215]

ui::TEST ( AXEventGeneratorTest  ,
TwoNodesSwapIgnored   
)

Definition at line 1150 of file ax_event_generator_unittest.cc.

1150 {
1151 AXTreeUpdate initial_state;
1152 initial_state.root_id = 1;
1153 initial_state.nodes.resize(3);
1154 initial_state.nodes[0].id = 1;
1155 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
1156 initial_state.nodes[0].child_ids.push_back(2);
1157 initial_state.nodes[1].id = 2;
1158 initial_state.nodes[1].role = ax::mojom::Role::kArticle;
1159 initial_state.nodes[1].child_ids.push_back(3);
1160 initial_state.nodes[2].id = 3;
1161 initial_state.nodes[2].role = ax::mojom::Role::kGroup;
1162 initial_state.nodes[2].AddState(ax::mojom::State::kIgnored);
1163
1164 AXTree tree(initial_state);
1165
1166 AXEventGenerator event_generator(&tree);
1167 AXTreeUpdate update = initial_state;
1168 update.nodes[1].AddState(ax::mojom::State::kIgnored);
1169 update.nodes[2].RemoveState(ax::mojom::State::kIgnored);
1170 ASSERT_TRUE(tree.Unserialize(update));
1172 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 1));
1174 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 2));
1176 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 3));
1178 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 3));
1179}

◆ TEST() [100/215]

ui::TEST ( AXEventGeneratorTest  ,
TwoNodesSwapIgnored2   
)

Definition at line 1181 of file ax_event_generator_unittest.cc.

1181 {
1182 AXTreeUpdate initial_state;
1183 initial_state.root_id = 1;
1184 initial_state.nodes.resize(3);
1185 initial_state.nodes[0].id = 1;
1186 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
1187 initial_state.nodes[0].child_ids.push_back(2);
1188 initial_state.nodes[1].id = 2;
1189 initial_state.nodes[1].role = ax::mojom::Role::kArticle;
1190 initial_state.nodes[1].AddState(ax::mojom::State::kIgnored);
1191 initial_state.nodes[1].child_ids.push_back(3);
1192 initial_state.nodes[2].id = 3;
1193 initial_state.nodes[2].role = ax::mojom::Role::kGroup;
1194
1195 AXTree tree(initial_state);
1196
1197 AXEventGenerator event_generator(&tree);
1198 AXTreeUpdate update = initial_state;
1199 update.nodes[1].RemoveState(ax::mojom::State::kIgnored);
1200 update.nodes[2].AddState(ax::mojom::State::kIgnored);
1201 ASSERT_TRUE(tree.Unserialize(update));
1203 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 1));
1205 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 2));
1207 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 3));
1209 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 2));
1210}

◆ TEST() [101/215]

ui::TEST ( AXNodeDataTest  ,
BitFieldsSanityCheck   
)

Definition at line 361 of file ax_node_data_unittest.cc.

361 {
362 EXPECT_LT(static_cast<size_t>(ax::mojom::State::kMaxValue),
363 sizeof(AXNodeData::state) * 8);
364 EXPECT_LT(static_cast<size_t>(ax::mojom::Action::kMaxValue),
365 sizeof(AXNodeData::actions) * 8);
366}

◆ TEST() [102/215]

ui::TEST ( AXNodeDataTest  ,
GetAndSetCheckedState   
)

Definition at line 19 of file ax_node_data_unittest.cc.

19 {
21 EXPECT_EQ(ax::mojom::CheckedState::kNone, root.GetCheckedState());
22 EXPECT_FALSE(root.HasIntAttribute(ax::mojom::IntAttribute::kCheckedState));
23
25 EXPECT_EQ(ax::mojom::CheckedState::kMixed, root.GetCheckedState());
27
29 EXPECT_EQ(ax::mojom::CheckedState::kFalse, root.GetCheckedState());
31
32 root.SetCheckedState(ax::mojom::CheckedState::kNone);
33 EXPECT_EQ(ax::mojom::CheckedState::kNone, root.GetCheckedState());
34 EXPECT_FALSE(root.HasIntAttribute(ax::mojom::IntAttribute::kCheckedState));
35}
string root
Definition: scale_cpu.py:20

◆ TEST() [103/215]

ui::TEST ( AXNodeDataTest  ,
IsButtonPressed   
)

Definition at line 89 of file ax_node_data_unittest.cc.

89 {
90 // A non-button element with CheckedState::kTrue should not return true for
91 // IsButtonPressed.
92 AXNodeData non_button_pressed;
93 non_button_pressed.role = ax::mojom::Role::kGenericContainer;
95 EXPECT_FALSE(IsButton(non_button_pressed.role));
96 EXPECT_FALSE(non_button_pressed.IsButtonPressed());
97
98 // A button element with CheckedState::kTrue should return true for
99 // IsButtonPressed.
100 AXNodeData button_pressed;
101 button_pressed.role = ax::mojom::Role::kButton;
103 EXPECT_TRUE(IsButton(button_pressed.role));
104 EXPECT_TRUE(button_pressed.IsButtonPressed());
105
106 button_pressed.role = ax::mojom::Role::kPopUpButton;
107 EXPECT_TRUE(IsButton(button_pressed.role));
108 EXPECT_TRUE(button_pressed.IsButtonPressed());
109
110 button_pressed.role = ax::mojom::Role::kToggleButton;
111 EXPECT_TRUE(IsButton(button_pressed.role));
112 EXPECT_TRUE(button_pressed.IsButtonPressed());
113
114 // A button element does not have CheckedState::kTrue should return false for
115 // IsButtonPressed.
116 AXNodeData button_not_pressed;
117 button_not_pressed.role = ax::mojom::Role::kButton;
119 EXPECT_TRUE(IsButton(button_not_pressed.role));
120 EXPECT_FALSE(button_not_pressed.IsButtonPressed());
121
122 button_not_pressed.role = ax::mojom::Role::kPopUpButton;
124 EXPECT_TRUE(IsButton(button_not_pressed.role));
125 EXPECT_FALSE(button_not_pressed.IsButtonPressed());
126
127 button_not_pressed.role = ax::mojom::Role::kToggleButton;
129 EXPECT_TRUE(IsButton(button_not_pressed.role));
130 EXPECT_FALSE(button_not_pressed.IsButtonPressed());
131}
bool IsButton(const ax::mojom::Role role)
bool IsButtonPressed() const
void SetCheckedState(ax::mojom::CheckedState checked_state)

◆ TEST() [104/215]

ui::TEST ( AXNodeDataTest  ,
IsClickable   
)

Definition at line 133 of file ax_node_data_unittest.cc.

133 {
134 // Test for ax node data attribute with a custom default action verb.
135 AXNodeData data_default_action_verb;
136
137 for (int action_verb_idx =
139 action_verb_idx <=
141 action_verb_idx++) {
142 data_default_action_verb.SetDefaultActionVerb(
143 static_cast<ax::mojom::DefaultActionVerb>(action_verb_idx));
144 bool is_clickable = data_default_action_verb.IsClickable();
145
146 SCOPED_TRACE(testing::Message()
147 << "ax::mojom::DefaultActionVerb="
148 << ToString(data_default_action_verb.GetDefaultActionVerb())
149 << ", Actual: isClickable=" << is_clickable
150 << ", Expected: isClickable=" << !is_clickable);
151
152 if (data_default_action_verb.GetDefaultActionVerb() ==
154 data_default_action_verb.GetDefaultActionVerb() ==
156 EXPECT_FALSE(is_clickable);
157 else
158 EXPECT_TRUE(is_clickable);
159 }
160
161 // Test for iterating through all roles and validate if a role is clickable.
162 std::set<ax::mojom::Role> roles_expected_is_clickable = {
194
195 AXNodeData data;
196
197 for (int role_idx = static_cast<int>(ax::mojom::Role::kMinValue);
198 role_idx <= static_cast<int>(ax::mojom::Role::kMaxValue); role_idx++) {
199 data.role = static_cast<ax::mojom::Role>(role_idx);
200 bool is_clickable = data.IsClickable();
201
202 SCOPED_TRACE(testing::Message()
203 << "ax::mojom::Role=" << ToString(data.role)
204 << ", Actual: isClickable=" << is_clickable
205 << ", Expected: isClickable=" << !is_clickable);
206
207 EXPECT_EQ(base::Contains(roles_expected_is_clickable, data.role),
208 is_clickable);
209 }
210}
DefaultActionVerb
Definition: ax_enums.h:489
bool Contains(const Container &container, const Value &value)
static std::string ToString(CompilerBackend::Type type)
Definition: reflector.cc:559
bool IsClickable() const
void SetDefaultActionVerb(ax::mojom::DefaultActionVerb default_action_verb)
ax::mojom::DefaultActionVerb GetDefaultActionVerb() const
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ TEST() [105/215]

ui::TEST ( AXNodeDataTest  ,
IsInvocable   
)

Definition at line 212 of file ax_node_data_unittest.cc.

212 {
213 // Test for iterating through all roles and validate if a role is invocable.
214 // A role is invocable if it is clickable and supports neither expand collapse
215 // nor toggle.
217 for (int role_idx = static_cast<int>(ax::mojom::Role::kMinValue);
218 role_idx <= static_cast<int>(ax::mojom::Role::kMaxValue); role_idx++) {
219 data.role = static_cast<ax::mojom::Role>(role_idx);
220 bool is_activatable = data.IsActivatable();
221 const bool supports_expand_collapse = data.SupportsExpandCollapse();
222 const bool supports_toggle = ui::SupportsToggle(data.role);
223 const bool is_clickable = data.IsClickable();
224 const bool is_invocable = data.IsInvocable();
225
226 SCOPED_TRACE(testing::Message()
227 << "ax::mojom::Role=" << ToString(data.role)
228 << ", isClickable=" << is_clickable << ", isActivatable="
229 << is_activatable << ", supportsToggle=" << supports_toggle
230 << ", supportsExpandCollapse=" << supports_expand_collapse
231 << ", Actual: isInvocable=" << is_invocable
232 << ", Expected: isInvocable=" << !is_invocable);
233
234 if (is_clickable && !is_activatable && !supports_toggle &&
235 !supports_expand_collapse)
236 EXPECT_TRUE(is_invocable);
237 else
238 EXPECT_FALSE(is_invocable);
239 }
240}
bool SupportsToggle(const ax::mojom::Role role)

◆ TEST() [106/215]

ui::TEST ( AXNodeDataTest  ,
IsMenuButton   
)

Definition at line 242 of file ax_node_data_unittest.cc.

242 {
243 // A non button element should return false for IsMenuButton.
244 AXNodeData non_button;
246 EXPECT_FALSE(IsButton(non_button.role));
247 EXPECT_FALSE(non_button.IsMenuButton());
248
249 // Only button element with HasPopup::kMenu should return true for
250 // IsMenuButton. All other ax::mojom::HasPopup types should return false.
251 AXNodeData button_with_popup;
252
253 button_with_popup.role = ax::mojom::Role::kButton;
254
255 for (int has_popup_idx = static_cast<int>(ax::mojom::HasPopup::kMinValue);
256 has_popup_idx <= static_cast<int>(ax::mojom::HasPopup::kMaxValue);
257 has_popup_idx++) {
258 button_with_popup.SetHasPopup(
259 static_cast<ax::mojom::HasPopup>(has_popup_idx));
260 bool is_menu_button = button_with_popup.IsMenuButton();
261
262 SCOPED_TRACE(testing::Message()
263 << "ax::mojom::Role=" << ToString(button_with_popup.role)
264 << ", hasPopup=" << ToString(button_with_popup.GetHasPopup())
265 << ", Actual: isMenuButton=" << is_menu_button
266 << ", Expected: isMenuButton=" << !is_menu_button);
267
268 if (IsButton(button_with_popup.role) &&
269 button_with_popup.GetHasPopup() == ax::mojom::HasPopup::kMenu)
270 EXPECT_TRUE(is_menu_button);
271 else
272 EXPECT_FALSE(is_menu_button);
273 }
274}
ax::mojom::HasPopup GetHasPopup() const
void SetHasPopup(ax::mojom::HasPopup has_popup)
bool IsMenuButton() const

◆ TEST() [107/215]

ui::TEST ( AXNodeDataTest  ,
SupportsExpandCollapse   
)

Definition at line 276 of file ax_node_data_unittest.cc.

276 {
277 // Test for iterating through all hasPopup attributes and validate if a
278 // hasPopup attribute supports expand collapse.
279 AXNodeData data_has_popup;
280
281 for (int has_popup_idx = static_cast<int>(ax::mojom::HasPopup::kMinValue);
282 has_popup_idx <= static_cast<int>(ax::mojom::HasPopup::kMaxValue);
283 has_popup_idx++) {
284 data_has_popup.SetHasPopup(static_cast<ax::mojom::HasPopup>(has_popup_idx));
285 bool supports_expand_collapse = data_has_popup.SupportsExpandCollapse();
286
287 SCOPED_TRACE(testing::Message() << "ax::mojom::HasPopup="
288 << ToString(data_has_popup.GetHasPopup())
289 << ", Actual: supportsExpandCollapse="
290 << supports_expand_collapse
291 << ", Expected: supportsExpandCollapse="
292 << !supports_expand_collapse);
293
294 if (data_has_popup.GetHasPopup() == ax::mojom::HasPopup::kFalse)
295 EXPECT_FALSE(supports_expand_collapse);
296 else
297 EXPECT_TRUE(supports_expand_collapse);
298 }
299
300 // Test for iterating through all states and validate if a state supports
301 // expand collapse.
302 AXNodeData data_state;
303
304 for (int state_idx = static_cast<int>(ax::mojom::State::kMinValue);
305 state_idx <= static_cast<int>(ax::mojom::State::kMaxValue);
306 state_idx++) {
307 ax::mojom::State state = static_cast<ax::mojom::State>(state_idx);
308
309 // skipping kNone here because AXNodeData::AddState, RemoveState forbids
310 // kNone to be added/removed and would fail DCHECK.
312 continue;
313
314 data_state.AddState(state);
315
316 bool supports_expand_collapse = data_state.SupportsExpandCollapse();
317
318 SCOPED_TRACE(testing::Message() << "ax::mojom::State=" << ToString(state)
319 << ", Actual: supportsExpandCollapse="
320 << supports_expand_collapse
321 << ", Expected: supportsExpandCollapse="
322 << !supports_expand_collapse);
323
324 if (data_state.HasState(ax::mojom::State::kExpanded) ||
325 data_state.HasState(ax::mojom::State::kCollapsed))
326 EXPECT_TRUE(supports_expand_collapse);
327 else
328 EXPECT_FALSE(supports_expand_collapse);
329
330 data_state.RemoveState(state);
331 }
332
333 // Test for iterating through all roles and validate if a role supports expand
334 // collapse.
335 AXNodeData data;
336
337 std::unordered_set<ax::mojom::Role> roles_expected_supports_expand_collapse =
341
342 for (int role_idx = static_cast<int>(ax::mojom::Role::kMinValue);
343 role_idx <= static_cast<int>(ax::mojom::Role::kMaxValue); role_idx++) {
344 data.role = static_cast<ax::mojom::Role>(role_idx);
345 bool supports_expand_collapse = data.SupportsExpandCollapse();
346
347 SCOPED_TRACE(testing::Message() << "ax::mojom::Role=" << ToString(data.role)
348 << ", Actual: supportsExpandCollapse="
349 << supports_expand_collapse
350 << ", Expected: supportsExpandCollapse="
351 << !supports_expand_collapse);
352
353 if (roles_expected_supports_expand_collapse.find(data.role) !=
354 roles_expected_supports_expand_collapse.end())
355 EXPECT_TRUE(supports_expand_collapse);
356 else
357 EXPECT_FALSE(supports_expand_collapse);
358 }
359}
bool SupportsExpandCollapse() const

◆ TEST() [108/215]

ui::TEST ( AXNodeDataTest  ,
TextAttributes   
)

Definition at line 37 of file ax_node_data_unittest.cc.

37 {
38 AXNodeData node_1;
40
41 AXNodeData node_2;
43 EXPECT_TRUE(node_1.GetTextStyles() == node_2.GetTextStyles());
44
46 EXPECT_TRUE(node_1.GetTextStyles() != node_2.GetTextStyles());
47
49 EXPECT_TRUE(node_1.GetTextStyles() == node_2.GetTextStyles());
50
52 EXPECT_TRUE(node_1.GetTextStyles() != node_2.GetTextStyles());
53
55 EXPECT_TRUE(node_1.GetTextStyles() == node_2.GetTextStyles());
56
58 "test font");
59 EXPECT_TRUE(node_1.GetTextStyles() != node_2.GetTextStyles());
60
62 "test font");
63 EXPECT_TRUE(node_1.GetTextStyles() == node_2.GetTextStyles());
64
66 EXPECT_TRUE(node_1.GetTextStyles() != node_2.GetTextStyles());
67
69 "test font");
70 EXPECT_TRUE(node_1.GetTextStyles() == node_2.GetTextStyles());
71
73 "different font");
74 EXPECT_TRUE(node_1.GetTextStyles() != node_2.GetTextStyles());
75
76 std::string tooltip;
78 "test tooltip");
80 &tooltip));
81 EXPECT_EQ(tooltip, "test tooltip");
82
83 AXNodeTextStyles node1_styles = node_1.GetTextStyles();
84 AXNodeTextStyles moved_styles = std::move(node1_styles);
85 EXPECT_TRUE(node1_styles != moved_styles);
86 EXPECT_TRUE(moved_styles == node_1.GetTextStyles());
87}
void AddFloatAttribute(ax::mojom::FloatAttribute attribute, float value)
void RemoveIntAttribute(ax::mojom::IntAttribute attribute)
void AddIntAttribute(ax::mojom::IntAttribute attribute, int32_t value)
AXNodeTextStyles GetTextStyles() const
void AddStringAttribute(ax::mojom::StringAttribute attribute, const std::string &value)
const std::string & GetStringAttribute(ax::mojom::StringAttribute attribute) const
void RemoveStringAttribute(ax::mojom::StringAttribute attribute)

◆ TEST() [109/215]

ui::TEST ( AXPlatformNodeBaseTest  ,
CompareTo   
)

Definition at line 405 of file ax_platform_node_base_unittest.cc.

405 {
406 // Compare the nodes' logical orders for the following tree. Node name is
407 // denoted according to its id (i.e. "n#" is id#). Nodes that have smaller ids
408 // are always logically less than nodes with bigger ids.
409 //
410 // n1
411 // |
412 // __ n2 ___
413 // / \ \
414 // n3 _ n8 n9
415 // / \ \ \
416 // n4 n5 n6 n10
417 // /
418 // n7
419 AXPlatformNode::NotifyAddAXModeFlags(kAXModeComplete);
420 AXNodeData node1;
421 node1.id = 1;
423 node1.child_ids = {2};
424
425 AXNodeData node2;
426 node2.id = 2;
427 node2.role = ax::mojom::Role::kStaticText;
428 node2.child_ids = {3, 8, 9};
429
430 AXNodeData node3;
431 node3.id = 3;
432 node3.role = ax::mojom::Role::kStaticText;
433 node3.child_ids = {4, 5, 6};
434
435 AXNodeData node4;
436 node4.id = 4;
437 node4.role = ax::mojom::Role::kStaticText;
438
439 AXNodeData node5;
440 node5.id = 5;
441 node5.role = ax::mojom::Role::kStaticText;
442
443 AXNodeData node6;
444 node6.id = 6;
445 node6.role = ax::mojom::Role::kStaticText;
446 node6.child_ids = {7};
447
448 AXNodeData node7;
449 node7.id = 7;
450 node7.role = ax::mojom::Role::kStaticText;
451
452 AXNodeData node8;
453 node8.id = 8;
454 node8.role = ax::mojom::Role::kStaticText;
455
456 AXNodeData node9;
457 node9.id = 9;
458 node9.role = ax::mojom::Role::kStaticText;
459 node9.child_ids = {10};
460
461 AXNodeData node10;
462 node10.id = 10;
463 node10.role = ax::mojom::Role::kStaticText;
464
466 update.root_id = 1;
467 update.nodes = {node1, node2, node3, node4, node5,
468 node6, node7, node8, node9, node10};
469
470 AXTree tree(update);
471
472 // Retrieve the nodes in a level-order traversal way.
473 auto* n1 = static_cast<AXPlatformNodeBase*>(
474 TestAXNodeWrapper::GetOrCreate(&tree, tree.root())->ax_platform_node());
475 auto* n2 = static_cast<AXPlatformNodeBase*>(
476 AXPlatformNode::FromNativeViewAccessible(n1->ChildAtIndex(0)));
477 auto* n3 = static_cast<AXPlatformNodeBase*>(
478 AXPlatformNode::FromNativeViewAccessible(n2->ChildAtIndex(0)));
479 auto* n8 = static_cast<AXPlatformNodeBase*>(
480 AXPlatformNode::FromNativeViewAccessible(n2->ChildAtIndex(1)));
481 auto* n9 = static_cast<AXPlatformNodeBase*>(
482 AXPlatformNode::FromNativeViewAccessible(n2->ChildAtIndex(2)));
483 auto* n4 = static_cast<AXPlatformNodeBase*>(
484 AXPlatformNode::FromNativeViewAccessible(n3->ChildAtIndex(0)));
485 auto* n5 = static_cast<AXPlatformNodeBase*>(
486 AXPlatformNode::FromNativeViewAccessible(n3->ChildAtIndex(1)));
487 auto* n6 = static_cast<AXPlatformNodeBase*>(
488 AXPlatformNode::FromNativeViewAccessible(n3->ChildAtIndex(2)));
489 auto* n10 = static_cast<AXPlatformNodeBase*>(
490 AXPlatformNode::FromNativeViewAccessible(n9->ChildAtIndex(0)));
491 auto* n7 = static_cast<AXPlatformNodeBase*>(
492 AXPlatformNode::FromNativeViewAccessible(n6->ChildAtIndex(0)));
493
494 // Test for two nodes that do not share the same root. They should not be
495 // comparable.
496 AXPlatformNodeBase detached_node;
497 EXPECT_EQ(std::nullopt, n1->CompareTo(detached_node));
498
499 // Create a test vector of all the tree nodes arranged in a pre-order
500 // traversal way. The node that has a smaller index in the vector should also
501 // be logically less (comes before) the nodes with bigger index.
502 std::vector<AXPlatformNodeBase*> preorder_tree_nodes = {n1, n2, n3, n4, n5,
503 n6, n7, n8, n9, n10};
504 // Test through all permutations of lhs/rhs comparisons of nodes from
505 // |preorder_tree_nodes|.
506 for (auto* lhs : preorder_tree_nodes) {
507 for (auto* rhs : preorder_tree_nodes) {
508 int expected_result = 0;
509 if (lhs->GetData().id < rhs->GetData().id)
510 expected_result = -1;
511 else if (lhs->GetData().id > rhs->GetData().id)
512 expected_result = 1;
513
514 EXPECT_NE(std::nullopt, lhs->CompareTo(*rhs));
515 int actual_result = 0;
516 if (lhs->CompareTo(*rhs) < 0)
517 actual_result = -1;
518 else if (lhs->CompareTo(*rhs) > 0)
519 actual_result = 1;
520
521 SCOPED_TRACE(testing::Message()
522 << "lhs.id=" << base::NumberToString(lhs->GetData().id)
523 << ", rhs.id=" << base::NumberToString(rhs->GetData().id)
524 << ", lhs->CompareTo(*rhs)={actual:"
525 << base::NumberToString(actual_result) << ", expected:"
526 << base::NumberToString(expected_result) << "}");
527
528 EXPECT_EQ(expected_result, actual_result);
529 }
530 }
531}
std::string NumberToString(int32_t number)
Definition: string_utils.cc:91
static constexpr AXMode kAXModeComplete(AXMode::kNativeAPIs|AXMode::kWebContents|AXMode::kInlineTextBoxes|AXMode::kScreenReader|AXMode::kHTML)
std::vector< int32_t > child_ids
Definition: ax_node_data.h:291

◆ TEST() [110/215]

ui::TEST ( AXPlatformNodeBaseTest  ,
GetHypertext   
)

Definition at line 48 of file ax_platform_node_base_unittest.cc.

48 {
50
51 // RootWebArea #1
52 // ++++StaticText "text1" #2
53 // ++++StaticText "text2" #3
54 // ++++StaticText "text3" #4
55
56 update.root_id = 1;
57 update.nodes.resize(4);
58
59 update.nodes[0].id = 1;
60 update.nodes[0].role = ax::mojom::Role::kWebArea;
61 update.nodes[0].child_ids = {2, 3, 4};
62
63 MakeStaticText(&update.nodes[1], 2, "text1");
64 MakeStaticText(&update.nodes[2], 3, "text2");
65 MakeStaticText(&update.nodes[3], 4, "text3");
66
67 AXTree tree(update);
68
69 // Set an AXMode on the AXPlatformNode as some platforms (auralinux) use it to
70 // determine if it should enable accessibility.
71 AXPlatformNodeBase::NotifyAddAXModeFlags(kAXModeComplete);
72
73 AXPlatformNodeBase* root = static_cast<AXPlatformNodeBase*>(
74 TestAXNodeWrapper::GetOrCreate(&tree, tree.root())->ax_platform_node());
75
76 EXPECT_EQ(root->GetHypertext(), base::UTF8ToUTF16("text1text2text3"));
77
78 AXPlatformNodeBase* text1 = static_cast<AXPlatformNodeBase*>(
79 AXPlatformNode::FromNativeViewAccessible(root->ChildAtIndex(0)));
80 EXPECT_EQ(text1->GetHypertext(), base::UTF8ToUTF16("text1"));
81
82 AXPlatformNodeBase* text2 = static_cast<AXPlatformNodeBase*>(
83 AXPlatformNode::FromNativeViewAccessible(root->ChildAtIndex(1)));
84 EXPECT_EQ(text2->GetHypertext(), base::UTF8ToUTF16("text2"));
85
86 AXPlatformNodeBase* text3 = static_cast<AXPlatformNodeBase*>(
87 AXPlatformNode::FromNativeViewAccessible(root->ChildAtIndex(2)));
88 EXPECT_EQ(text3->GetHypertext(), base::UTF8ToUTF16("text3"));
89}
std::u16string UTF8ToUTF16(std::string src)
Definition: string_utils.cc:67

◆ TEST() [111/215]

ui::TEST ( AXPlatformNodeBaseTest  ,
GetHypertextIgnoredContainerSiblings   
)

Definition at line 91 of file ax_platform_node_base_unittest.cc.

91 {
93
94 // RootWebArea #1
95 // ++genericContainer IGNORED #2
96 // ++++StaticText "text1" #3
97 // ++genericContainer IGNORED #4
98 // ++++StaticText "text2" #5
99 // ++genericContainer IGNORED #6
100 // ++++StaticText "text3" #7
101
102 update.root_id = 1;
103 update.nodes.resize(7);
104
105 update.nodes[0].id = 1;
106 update.nodes[0].role = ax::mojom::Role::kWebArea;
107 update.nodes[0].child_ids = {2, 4, 6};
108
109 update.nodes[1].id = 2;
110 update.nodes[1].child_ids = {3};
112 update.nodes[1].AddState(ax::mojom::State::kIgnored);
113 MakeStaticText(&update.nodes[2], 3, "text1");
114
115 update.nodes[3].id = 4;
116 update.nodes[3].child_ids = {5};
118 update.nodes[3].AddState(ax::mojom::State::kIgnored);
119 MakeStaticText(&update.nodes[4], 5, "text2");
120
121 update.nodes[5].id = 6;
122 update.nodes[5].child_ids = {7};
124 update.nodes[5].AddState(ax::mojom::State::kIgnored);
125 MakeStaticText(&update.nodes[6], 7, "text3");
126
127 AXTree tree(update);
128 // Set an AXMode on the AXPlatformNode as some platforms (auralinux) use it to
129 // determine if it should enable accessibility.
130 AXPlatformNodeBase::NotifyAddAXModeFlags(kAXModeComplete);
131
132 AXPlatformNodeBase* root = static_cast<AXPlatformNodeBase*>(
133 TestAXNodeWrapper::GetOrCreate(&tree, tree.root())->ax_platform_node());
134
135 EXPECT_EQ(root->GetHypertext(), base::UTF8ToUTF16("text1text2text3"));
136
137 AXPlatformNodeBase* text1_ignored_container =
138 static_cast<AXPlatformNodeBase*>(
139 AXPlatformNode::FromNativeViewAccessible(root->ChildAtIndex(0)));
140 EXPECT_EQ(text1_ignored_container->GetHypertext(),
141 base::UTF8ToUTF16("text1"));
142
143 AXPlatformNodeBase* text2_ignored_container =
144 static_cast<AXPlatformNodeBase*>(
145 AXPlatformNode::FromNativeViewAccessible(root->ChildAtIndex(1)));
146 EXPECT_EQ(text2_ignored_container->GetHypertext(),
147 base::UTF8ToUTF16("text2"));
148
149 AXPlatformNodeBase* text3_ignored_container =
150 static_cast<AXPlatformNodeBase*>(
151 AXPlatformNode::FromNativeViewAccessible(root->ChildAtIndex(2)));
152 EXPECT_EQ(text3_ignored_container->GetHypertext(),
153 base::UTF8ToUTF16("text3"));
154}

◆ TEST() [112/215]

ui::TEST ( AXPlatformNodeBaseTest  ,
InnerTextIgnoresInvisibleAndIgnored   
)

Definition at line 156 of file ax_platform_node_base_unittest.cc.

156 {
158
159 update.root_id = 1;
160 update.nodes.resize(6);
161
162 MakeStaticText(&update.nodes[1], 2, "a");
163 MakeStaticText(&update.nodes[2], 3, "b");
164
165 MakeStaticText(&update.nodes[4], 5, "d");
166 MakeStaticText(&update.nodes[5], 6, "e");
167
168 MakeGroup(&update.nodes[3], 4, {5, 6});
169 MakeGroup(&update.nodes[0], 1, {2, 3, 4});
170
171 AXTree tree(update);
172
173 auto* root = static_cast<AXPlatformNodeBase*>(
174 TestAXNodeWrapper::GetOrCreate(&tree, tree.root())->ax_platform_node());
175
176 // Set an AXMode on the AXPlatformNode as some platforms (auralinux) use it to
177 // determine if it should enable accessibility.
178 AXPlatformNodeBase::NotifyAddAXModeFlags(kAXModeComplete);
179
180 EXPECT_EQ(root->GetInnerText(), base::UTF8ToUTF16("abde"));
181
182 // Setting invisible or ignored on a static text node causes it to be included
183 // or excluded from the root node's inner text:
184 {
185 SetIsInvisible(&tree, 2, true);
186 EXPECT_EQ(root->GetInnerText(), base::UTF8ToUTF16("bde"));
187
188 SetIsInvisible(&tree, 2, false);
189 EXPECT_EQ(root->GetInnerText(), base::UTF8ToUTF16("abde"));
190
191 SetRole(&tree, 2, ax::mojom::Role::kIgnored);
192 EXPECT_EQ(root->GetInnerText(), base::UTF8ToUTF16("bde"));
193
194 SetRole(&tree, 2, ax::mojom::Role::kStaticText);
195 EXPECT_EQ(root->GetInnerText(), base::UTF8ToUTF16("abde"));
196 }
197
198 // Setting invisible or ignored on a group node has no effect on the inner
199 // text:
200 {
201 SetIsInvisible(&tree, 4, true);
202 EXPECT_EQ(root->GetInnerText(), base::UTF8ToUTF16("abde"));
203
204 SetRole(&tree, 4, ax::mojom::Role::kIgnored);
205 EXPECT_EQ(root->GetInnerText(), base::UTF8ToUTF16("abde"));
206 }
207}

◆ TEST() [113/215]

ui::TEST ( AXPlatformNodeBaseTest  ,
TestSelectedChildren   
)

Definition at line 209 of file ax_platform_node_base_unittest.cc.

209 {
210 AXPlatformNode::NotifyAddAXModeFlags(kAXModeComplete);
211
212 AXNodeData root_data;
213 root_data.id = 1;
216 root_data.child_ids = {2, 3};
217
218 AXNodeData item_1_data;
219 item_1_data.id = 2;
220 item_1_data.role = ax::mojom::Role::kListBoxOption;
221 item_1_data.AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, true);
222
223 AXNodeData item_2_data;
224 item_2_data.id = 3;
225 item_2_data.role = ax::mojom::Role::kListBoxOption;
226
228 update.root_id = 1;
229 update.nodes = {root_data, item_1_data, item_2_data};
230 AXTree tree(update);
231
232 auto* root = static_cast<AXPlatformNodeBase*>(
233 TestAXNodeWrapper::GetOrCreate(&tree, tree.root())->ax_platform_node());
234
235 int num = root->GetSelectionCount();
236 EXPECT_EQ(num, 1);
237
238 gfx::NativeViewAccessible first_child = root->ChildAtIndex(0);
239 AXPlatformNodeBase* first_selected_node = root->GetSelectedItem(0);
240 EXPECT_EQ(first_child, first_selected_node->GetNativeViewAccessible());
241 EXPECT_EQ(nullptr, root->GetSelectedItem(1));
242}
UnimplementedNativeViewAccessible * NativeViewAccessible
void AddState(ax::mojom::State state)

◆ TEST() [114/215]

ui::TEST ( AXPlatformNodeBaseTest  ,
TestSelectedChildrenMixed   
)

Definition at line 310 of file ax_platform_node_base_unittest.cc.

310 {
311 AXPlatformNode::NotifyAddAXModeFlags(kAXModeComplete);
312
313 // Build the below tree which is mixed with listBoxOption and group.
314 // id=1 listBox FOCUSABLE MULTISELECTABLE (0, 0)-(0, 0) child_ids=2,3,4,9
315 // ++id=2 listBoxOption (0, 0)-(0, 0) selected=true
316 // ++id=3 group (0, 0)-(0, 0) child_ids=5,6
317 // ++++id=5 listBoxOption (0, 0)-(0, 0) selected=true
318 // ++++id=6 listBoxOption (0, 0)-(0, 0)
319 // ++id=4 group (0, 0)-(0, 0) child_ids=7,8
320 // ++++id=7 listBoxOption (0, 0)-(0, 0)
321 // ++++id=8 listBoxOption (0, 0)-(0, 0) selected=true
322 // ++id=9 listBoxOption (0, 0)-(0, 0) selected=true
323
324 AXNodeData root_data;
325 root_data.id = 1;
329 root_data.child_ids = {2, 3, 4, 9};
330
331 AXNodeData item_1_data;
332 item_1_data.id = 2;
333 item_1_data.role = ax::mojom::Role::kListBoxOption;
334 item_1_data.AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, true);
335
336 AXNodeData group_1_data;
337 group_1_data.id = 3;
338 group_1_data.role = ax::mojom::Role::kGroup;
339 group_1_data.child_ids = {5, 6};
340
341 AXNodeData item_2_data;
342 item_2_data.id = 5;
343 item_2_data.role = ax::mojom::Role::kListBoxOption;
344 item_2_data.AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, true);
345
346 AXNodeData item_3_data;
347 item_3_data.id = 6;
348 item_3_data.role = ax::mojom::Role::kListBoxOption;
349
350 AXNodeData group_2_data;
351 group_2_data.id = 4;
352 group_2_data.role = ax::mojom::Role::kGroup;
353 group_2_data.child_ids = {7, 8};
354
355 AXNodeData item_4_data;
356 item_4_data.id = 7;
357 item_4_data.role = ax::mojom::Role::kListBoxOption;
358
359 AXNodeData item_5_data;
360 item_5_data.id = 8;
361 item_5_data.role = ax::mojom::Role::kListBoxOption;
362 item_5_data.AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, true);
363
364 AXNodeData item_6_data;
365 item_6_data.id = 9;
366 item_6_data.role = ax::mojom::Role::kListBoxOption;
367 item_6_data.AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, true);
368
370 update.root_id = 1;
371 update.nodes = {root_data, item_1_data, group_1_data,
372 item_2_data, item_3_data, group_2_data,
373 item_4_data, item_5_data, item_6_data};
374 AXTree tree(update);
375
376 auto* root = static_cast<AXPlatformNodeBase*>(
377 TestAXNodeWrapper::GetOrCreate(&tree, tree.root())->ax_platform_node());
378
379 int num = root->GetSelectionCount();
380 EXPECT_EQ(num, 4);
381
382 gfx::NativeViewAccessible first_child = root->ChildAtIndex(0);
383 AXPlatformNodeBase* first_selected_node = root->GetSelectedItem(0);
384 EXPECT_EQ(first_child, first_selected_node->GetNativeViewAccessible());
385
386 gfx::NativeViewAccessible first_group_child =
387 static_cast<AXPlatformNodeBase*>(
388 AXPlatformNode::FromNativeViewAccessible(root->ChildAtIndex(1)))
389 ->ChildAtIndex(0);
390 AXPlatformNodeBase* second_selected_node = root->GetSelectedItem(1);
391 EXPECT_EQ(first_group_child, second_selected_node->GetNativeViewAccessible());
392
393 gfx::NativeViewAccessible second_group_child =
394 static_cast<AXPlatformNodeBase*>(
395 AXPlatformNode::FromNativeViewAccessible(root->ChildAtIndex(2)))
396 ->ChildAtIndex(1);
397 AXPlatformNodeBase* third_selected_node = root->GetSelectedItem(2);
398 EXPECT_EQ(second_group_child, third_selected_node->GetNativeViewAccessible());
399
400 gfx::NativeViewAccessible fourth_child = root->ChildAtIndex(3);
401 AXPlatformNodeBase* fourth_selected_node = root->GetSelectedItem(3);
402 EXPECT_EQ(fourth_child, fourth_selected_node->GetNativeViewAccessible());
403}

◆ TEST() [115/215]

ui::TEST ( AXPlatformNodeBaseTest  ,
TestSelectedChildrenWithGroup   
)

Definition at line 244 of file ax_platform_node_base_unittest.cc.

244 {
245 AXPlatformNode::NotifyAddAXModeFlags(kAXModeComplete);
246
247 AXNodeData root_data;
248 root_data.id = 1;
252 root_data.child_ids = {2, 3};
253
254 AXNodeData group_1_data;
255 group_1_data.id = 2;
256 group_1_data.role = ax::mojom::Role::kGroup;
257 group_1_data.child_ids = {4, 5};
258
259 AXNodeData group_2_data;
260 group_2_data.id = 3;
261 group_2_data.role = ax::mojom::Role::kGroup;
262 group_2_data.child_ids = {6, 7};
263
264 AXNodeData item_1_data;
265 item_1_data.id = 4;
266 item_1_data.role = ax::mojom::Role::kListBoxOption;
267 item_1_data.AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, true);
268
269 AXNodeData item_2_data;
270 item_2_data.id = 5;
271 item_2_data.role = ax::mojom::Role::kListBoxOption;
272
273 AXNodeData item_3_data;
274 item_3_data.id = 6;
275 item_3_data.role = ax::mojom::Role::kListBoxOption;
276
277 AXNodeData item_4_data;
278 item_4_data.id = 7;
279 item_4_data.role = ax::mojom::Role::kListBoxOption;
280 item_4_data.AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, true);
281
283 update.root_id = 1;
284 update.nodes = {root_data, group_1_data, group_2_data, item_1_data,
285 item_2_data, item_3_data, item_4_data};
286 AXTree tree(update);
287
288 auto* root = static_cast<AXPlatformNodeBase*>(
289 TestAXNodeWrapper::GetOrCreate(&tree, tree.root())->ax_platform_node());
290
291 int num = root->GetSelectionCount();
292 EXPECT_EQ(num, 2);
293
294 gfx::NativeViewAccessible first_group_child =
295 static_cast<AXPlatformNodeBase*>(
296 AXPlatformNode::FromNativeViewAccessible(root->ChildAtIndex(0)))
297 ->ChildAtIndex(0);
298 AXPlatformNodeBase* first_selected_node = root->GetSelectedItem(0);
299 EXPECT_EQ(first_group_child, first_selected_node->GetNativeViewAccessible());
300
301 gfx::NativeViewAccessible second_group_child =
302 static_cast<AXPlatformNodeBase*>(
303 AXPlatformNode::FromNativeViewAccessible(root->ChildAtIndex(1)))
304 ->ChildAtIndex(1);
305 AXPlatformNodeBase* second_selected_node = root->GetSelectedItem(1);
306 EXPECT_EQ(second_group_child,
307 second_selected_node->GetNativeViewAccessible());
308}

◆ TEST() [116/215]

ui::TEST ( AXPlatformUniqueIdTest  ,
DoesCreateCorrectId   
)

Definition at line 56 of file ax_unique_id_unittest.cc.

56 {
57 constexpr int kLargerThanMaxId = kMaxId * 2;
58 std::unique_ptr<AXUniqueId> ids[kLargerThanMaxId];
59 // Creates and releases to fill up the internal static counter.
60 for (int i = 0; i < kLargerThanMaxId; i++) {
61 ids[i] = std::make_unique<AXUniqueId>();
62 }
63 for (int i = 0; i < kLargerThanMaxId; i++) {
64 ids[i].reset(nullptr);
65 }
66 // Creates an unique id whose max value is less than the internal
67 // static counter.
68 std::unique_ptr<AXTestSmallBankUniqueId> unique_id =
69 std::make_unique<AXTestSmallBankUniqueId>();
70
71 EXPECT_LE(unique_id->Get(), kMaxId);
72}
static const int32_t kMaxId

◆ TEST() [117/215]

ui::TEST ( AXPlatformUniqueIdTest  ,
IdsAreUnique   
)

Definition at line 13 of file ax_unique_id_unittest.cc.

13 {
14 AXUniqueId id1, id2;
15 EXPECT_FALSE(id1 == id2);
16 EXPECT_GT(id2.Get(), id1.Get());
17}
int32_t Get() const
Definition: ax_unique_id.h:30

◆ TEST() [118/215]

ui::TEST ( AXPlatformUniqueIdTest  ,
UnassignedIdsAreReused   
)

Definition at line 34 of file ax_unique_id_unittest.cc.

34 {
35 // Create a bank of ids that uses up all available ids.
36 // Then remove an id and replace with a new one. Since it's the only
37 // slot available, the id will end up having the same value, rather than
38 // starting over at 1.
39 std::unique_ptr<AXTestSmallBankUniqueId> ids[kMaxId];
40
41 for (int i = 0; i < kMaxId; i++) {
42 ids[i] = std::make_unique<AXTestSmallBankUniqueId>();
43 }
44
45 static int kIdToReplace = 10;
46 int32_t expected_id = ids[kIdToReplace]->Get();
47
48 // Delete one of the ids and replace with a new one.
49 ids[kIdToReplace] = nullptr;
50 ids[kIdToReplace] = std::make_unique<AXTestSmallBankUniqueId>();
51
52 // Expect that the original Id gets reused.
53 EXPECT_EQ(ids[kIdToReplace]->Get(), expected_id);
54}
const GrXPFactory * Get(SkBlendMode mode)

◆ TEST() [119/215]

ui::TEST ( AXRolePropertiesTest  ,
TestSupportsHierarchicalLevel   
)

Definition at line 15 of file ax_role_properties_unittest.cc.

15 {
16 // Test for iterating through all roles and validate if a role supports
17 // hierarchical level.
18 std::unordered_set<ax::mojom::Role>
19 roles_expected_supports_hierarchical_level = {
23
24 for (int role_idx = static_cast<int>(ax::mojom::Role::kMinValue);
25 role_idx <= static_cast<int>(ax::mojom::Role::kMaxValue); role_idx++) {
26 ax::mojom::Role role = static_cast<ax::mojom::Role>(role_idx);
27 bool supports_hierarchical_level = SupportsHierarchicalLevel(role);
28
29 SCOPED_TRACE(testing::Message() << "ax::mojom::Role=" << ToString(role)
30 << ", Actual: supportsHierarchicalLevel="
31 << supports_hierarchical_level
32 << ", Expected: supportsHierarchicalLevel="
33 << !supports_hierarchical_level);
34
35 if (roles_expected_supports_hierarchical_level.find(role) !=
36 roles_expected_supports_hierarchical_level.end())
37 EXPECT_TRUE(supports_hierarchical_level);
38 else
39 EXPECT_FALSE(supports_hierarchical_level);
40 }
41}
bool SupportsHierarchicalLevel(const ax::mojom::Role role)

◆ TEST() [120/215]

ui::TEST ( AXRolePropertiesTest  ,
TestSupportsToggle   
)

Definition at line 43 of file ax_role_properties_unittest.cc.

43 {
44 // Test for iterating through all roles and validate if a role supports
45 // toggle.
46 std::unordered_set<ax::mojom::Role> roles_expected_supports_toggle = {
49
50 for (int role_idx = static_cast<int>(ax::mojom::Role::kMinValue);
51 role_idx <= static_cast<int>(ax::mojom::Role::kMaxValue); role_idx++) {
52 ax::mojom::Role role = static_cast<ax::mojom::Role>(role_idx);
53 bool supports_toggle = SupportsToggle(role);
54
55 SCOPED_TRACE(testing::Message()
56 << "ax::mojom::Role=" << ToString(role)
57 << ", Actual: supportsToggle=" << supports_toggle
58 << ", Expected: supportsToggle=" << !supports_toggle);
59
60 if (roles_expected_supports_toggle.find(role) !=
61 roles_expected_supports_toggle.end())
62 EXPECT_TRUE(supports_toggle);
63 else
64 EXPECT_FALSE(supports_toggle);
65 }
66}

◆ TEST() [121/215]

ui::TEST ( AXTreeTest  ,
AttributeChangeCallbacks   
)

Definition at line 1126 of file ax_tree_unittest.cc.

1126 {
1127 AXTreeUpdate initial_state;
1128 initial_state.root_id = 1;
1129 initial_state.nodes.resize(1);
1130 initial_state.nodes[0].id = 1;
1131 initial_state.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kName,
1132 "N1");
1133 initial_state.nodes[0].AddStringAttribute(
1135 initial_state.nodes[0].AddBoolAttribute(ax::mojom::BoolAttribute::kLiveAtomic,
1136 true);
1137 initial_state.nodes[0].AddBoolAttribute(ax::mojom::BoolAttribute::kBusy,
1138 false);
1139 initial_state.nodes[0].AddFloatAttribute(
1141 initial_state.nodes[0].AddFloatAttribute(
1143 initial_state.nodes[0].AddFloatAttribute(
1145 initial_state.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kScrollX, 5);
1146 initial_state.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kScrollXMin,
1147 1);
1148 AXTree tree(initial_state);
1149
1150 TestAXTreeObserver test_observer(&tree);
1151
1152 // Change existing attributes.
1153 AXTreeUpdate update0;
1154 update0.root_id = 1;
1155 update0.nodes.resize(1);
1156 update0.nodes[0].id = 1;
1157 update0.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kName, "N2");
1158 update0.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kDescription,
1159 "D2");
1160 update0.nodes[0].AddBoolAttribute(ax::mojom::BoolAttribute::kLiveAtomic,
1161 false);
1162 update0.nodes[0].AddBoolAttribute(ax::mojom::BoolAttribute::kBusy, true);
1163 update0.nodes[0].AddFloatAttribute(
1165 update0.nodes[0].AddFloatAttribute(
1167 update0.nodes[0].AddFloatAttribute(
1169 update0.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kScrollX, 6);
1170 update0.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kScrollXMin, 2);
1171 EXPECT_TRUE(tree.Unserialize(update0));
1172
1173 const std::vector<std::string>& change_log =
1174 test_observer.attribute_change_log();
1175 ASSERT_EQ(9U, change_log.size());
1176 EXPECT_EQ("name changed from N1 to N2", change_log[0]);
1177 EXPECT_EQ("description changed from D1 to D2", change_log[1]);
1178 EXPECT_EQ("liveAtomic changed to false", change_log[2]);
1179 EXPECT_EQ("busy changed to true", change_log[3]);
1180 EXPECT_EQ("minValueForRange changed from 1.0 to 2.0", change_log[4]);
1181 EXPECT_EQ("maxValueForRange changed from 10.0 to 9.0", change_log[5]);
1182 EXPECT_EQ("stepValueForRange changed from 3.0 to 0.5", change_log[6]);
1183 EXPECT_EQ("scrollX changed from 5 to 6", change_log[7]);
1184 EXPECT_EQ("scrollXMin changed from 1 to 2", change_log[8]);
1185
1186 TestAXTreeObserver test_observer2(&tree);
1187
1188 // Add and remove attributes.
1189 AXTreeUpdate update1;
1190 update1.root_id = 1;
1191 update1.nodes.resize(1);
1192 update1.nodes[0].id = 1;
1193 update1.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kDescription,
1194 "D3");
1195 update1.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kValue, "V3");
1196 update1.nodes[0].AddBoolAttribute(ax::mojom::BoolAttribute::kModal, true);
1197 update1.nodes[0].AddFloatAttribute(ax::mojom::FloatAttribute::kValueForRange,
1198 5.0);
1199 update1.nodes[0].AddFloatAttribute(
1201 update1.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kScrollX, 7);
1202 update1.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kScrollXMax, 10);
1203 EXPECT_TRUE(tree.Unserialize(update1));
1204
1205 const std::vector<std::string>& change_log2 =
1206 test_observer2.attribute_change_log();
1207 ASSERT_EQ(11U, change_log2.size());
1208 EXPECT_EQ("name changed from N2 to ", change_log2[0]);
1209 EXPECT_EQ("description changed from D2 to D3", change_log2[1]);
1210 EXPECT_EQ("value changed from to V3", change_log2[2]);
1211 EXPECT_EQ("busy changed to false", change_log2[3]);
1212 EXPECT_EQ("modal changed to true", change_log2[4]);
1213 EXPECT_EQ("minValueForRange changed from 2.0 to 0.0", change_log2[5]);
1214 EXPECT_EQ("stepValueForRange changed from 3.0 to 0.5", change_log[6]);
1215 EXPECT_EQ("valueForRange changed from 0.0 to 5.0", change_log2[7]);
1216 EXPECT_EQ("scrollXMin changed from 2 to 0", change_log2[8]);
1217 EXPECT_EQ("scrollX changed from 6 to 7", change_log2[9]);
1218 EXPECT_EQ("scrollXMax changed from 0 to 10", change_log2[10]);
1219}

◆ TEST() [122/215]

ui::TEST ( AXTreeTest  ,
BogusAXTree   
)

Definition at line 1052 of file ax_tree_unittest.cc.

1052 {
1053 AXTreeUpdate initial_state;
1054 AXNodeData node;
1055 node.id = 0;
1056 initial_state.nodes.push_back(node);
1057 initial_state.nodes.push_back(node);
1058 ui::AXTree tree;
1059 tree.Unserialize(initial_state);
1060}
virtual bool Unserialize(const AXTreeUpdate &update)
Definition: ax_tree.cc:969

◆ TEST() [123/215]

ui::TEST ( AXTreeTest  ,
BogusAXTree2   
)

Definition at line 1063 of file ax_tree_unittest.cc.

1063 {
1064 AXTreeUpdate initial_state;
1065 AXNodeData node;
1066 node.id = 0;
1067 initial_state.nodes.push_back(node);
1068 AXNodeData node2;
1069 node2.id = 0;
1070 node2.child_ids.push_back(0);
1071 node2.child_ids.push_back(0);
1072 initial_state.nodes.push_back(node2);
1073 ui::AXTree tree;
1074 tree.Unserialize(initial_state);
1075}

◆ TEST() [124/215]

ui::TEST ( AXTreeTest  ,
BogusAXTree3   
)

Definition at line 1078 of file ax_tree_unittest.cc.

1078 {
1079 AXTreeUpdate initial_state;
1080 AXNodeData node;
1081 node.id = 0;
1082 node.child_ids.push_back(1);
1083 initial_state.nodes.push_back(node);
1084
1085 AXNodeData node2;
1086 node2.id = 1;
1087 node2.child_ids.push_back(1);
1088 node2.child_ids.push_back(1);
1089 initial_state.nodes.push_back(node2);
1090
1091 ui::AXTree tree;
1092 tree.Unserialize(initial_state);
1093}

◆ TEST() [125/215]

ui::TEST ( AXTreeTest  ,
CachedUnignoredValues   
)

Definition at line 1819 of file ax_tree_unittest.cc.

1819 {
1820 AXTreeUpdate initial_state;
1821 initial_state.root_id = 1;
1822 initial_state.nodes.resize(5);
1823 initial_state.nodes[0].id = 1;
1824 initial_state.nodes[0].child_ids = {2, 3};
1825 initial_state.nodes[1].id = 2;
1826 initial_state.nodes[1].AddState(ax::mojom::State::kIgnored);
1827 initial_state.nodes[1].child_ids = {4, 5};
1828 initial_state.nodes[2].id = 3;
1829 initial_state.nodes[3].id = 4;
1830 initial_state.nodes[4].id = 5;
1831
1832 AXTree tree(initial_state);
1833 AXNode* root = tree.root();
1834 ASSERT_EQ(2u, root->children().size());
1835 ASSERT_EQ(2, root->children()[0]->id());
1836 ASSERT_EQ(3, root->children()[1]->id());
1837
1838 EXPECT_EQ(3u, root->GetUnignoredChildCount());
1839 EXPECT_EQ(4, root->GetUnignoredChildAtIndex(0)->id());
1840 EXPECT_EQ(5, root->GetUnignoredChildAtIndex(1)->id());
1841 EXPECT_EQ(3, root->GetUnignoredChildAtIndex(2)->id());
1842 EXPECT_EQ(0u, root->GetUnignoredChildAtIndex(0)->GetUnignoredIndexInParent());
1843 EXPECT_EQ(1u, root->GetUnignoredChildAtIndex(1)->GetUnignoredIndexInParent());
1844 EXPECT_EQ(2u, root->GetUnignoredChildAtIndex(2)->GetUnignoredIndexInParent());
1845
1846 EXPECT_EQ(1, root->GetUnignoredChildAtIndex(0)->GetUnignoredParent()->id());
1847
1848 // Ensure when a node goes from ignored to unignored, its children have their
1849 // unignored_index_in_parent updated.
1850 AXTreeUpdate update = initial_state;
1851 update.nodes[1].RemoveState(ax::mojom::State::kIgnored);
1852
1853 EXPECT_TRUE(tree.Unserialize(update));
1854
1855 root = tree.root();
1856 EXPECT_EQ(2u, root->GetUnignoredChildCount());
1857 EXPECT_EQ(2, root->GetUnignoredChildAtIndex(0)->id());
1858 EXPECT_EQ(2u, tree.GetFromId(2)->GetUnignoredChildCount());
1859 EXPECT_EQ(0u, tree.GetFromId(4)->GetUnignoredIndexInParent());
1860 EXPECT_EQ(1u, tree.GetFromId(5)->GetUnignoredIndexInParent());
1861
1862 // Ensure when a node goes from unignored to unignored, siblings are correctly
1863 // updated.
1864 AXTreeUpdate update2 = update;
1865 update2.nodes[3].AddState(ax::mojom::State::kIgnored);
1866
1867 EXPECT_TRUE(tree.Unserialize(update2));
1868
1869 EXPECT_EQ(1u, tree.GetFromId(2)->GetUnignoredChildCount());
1870 EXPECT_EQ(0u, tree.GetFromId(5)->GetUnignoredIndexInParent());
1871
1872 // Ensure siblings of a deleted node are updated.
1873 AXTreeUpdate update3 = update2;
1874 update3.nodes.resize(1);
1875 update3.nodes[0].id = 1;
1876 update3.nodes[0].child_ids = {3};
1877
1878 EXPECT_TRUE(tree.Unserialize(update3));
1879
1880 EXPECT_EQ(1u, tree.GetFromId(1)->GetUnignoredChildCount());
1881 EXPECT_EQ(0u, tree.GetFromId(3)->GetUnignoredIndexInParent());
1882
1883 // Ensure new nodes are correctly updated.
1884 AXTreeUpdate update4 = update3;
1885 update4.nodes.resize(3);
1886 update4.nodes[0].id = 1;
1887 update4.nodes[0].child_ids = {3, 6};
1888 update4.nodes[1].id = 6;
1889 update4.nodes[1].child_ids = {7};
1890 update4.nodes[2].id = 7;
1891
1892 EXPECT_TRUE(tree.Unserialize(update4));
1893
1894 EXPECT_EQ(2u, tree.GetFromId(1)->GetUnignoredChildCount());
1895 EXPECT_EQ(0u, tree.GetFromId(3)->GetUnignoredIndexInParent());
1896 EXPECT_EQ(1u, tree.GetFromId(6)->GetUnignoredIndexInParent());
1897 EXPECT_EQ(0u, tree.GetFromId(7)->GetUnignoredIndexInParent());
1898
1899 // Ensure reparented nodes are correctly updated.
1900 AXTreeUpdate update5 = update4;
1901 update5.nodes.resize(2);
1902 update5.node_id_to_clear = 6;
1903 update5.nodes[0].id = 1;
1904 update5.nodes[0].child_ids = {3, 7};
1905 update5.nodes[1].id = 7;
1906 update5.nodes[1].child_ids = {};
1907
1908 EXPECT_TRUE(tree.Unserialize(update5));
1909
1910 EXPECT_EQ(2u, tree.GetFromId(1)->GetUnignoredChildCount());
1911 EXPECT_EQ(0u, tree.GetFromId(3)->GetUnignoredIndexInParent());
1912 EXPECT_EQ(1u, tree.GetFromId(7)->GetUnignoredIndexInParent());
1913
1914 AXTreeUpdate update6;
1915 update6.nodes.resize(1);
1916 update6.nodes[0].id = 7;
1917 update6.nodes[0].AddState(ax::mojom::State::kIgnored);
1918
1919 EXPECT_TRUE(tree.Unserialize(update6));
1920
1921 EXPECT_EQ(1u, tree.GetFromId(1)->GetUnignoredChildCount());
1922 EXPECT_EQ(0u, tree.GetFromId(3)->GetUnignoredIndexInParent());
1923
1924 AXTreeUpdate update7 = update6;
1925 update7.nodes.resize(2);
1926 update7.nodes[0].id = 7;
1927 update7.nodes[0].child_ids = {8};
1928 update7.nodes[1].id = 8;
1929
1930 EXPECT_TRUE(tree.Unserialize(update7));
1931
1932 EXPECT_EQ(2u, tree.GetFromId(1)->GetUnignoredChildCount());
1933 EXPECT_EQ(0u, tree.GetFromId(3)->GetUnignoredIndexInParent());
1934}

◆ TEST() [126/215]

ui::TEST ( AXTreeTest  ,
DeletingNodeUpdatesReverseRelations   
)

Definition at line 1701 of file ax_tree_unittest.cc.

1701 {
1702 AXTreeUpdate initial_state;
1703 initial_state.root_id = 1;
1704 initial_state.nodes.resize(3);
1705 initial_state.nodes[0].id = 1;
1706 initial_state.nodes[0].child_ids = {2, 3};
1707 initial_state.nodes[1].id = 2;
1708 initial_state.nodes[2].id = 3;
1709 initial_state.nodes[2].AddIntAttribute(
1711 AXTree tree(initial_state);
1712
1713 auto reverse_active_descendant =
1714 tree.GetReverseRelations(ax::mojom::IntAttribute::kActivedescendantId, 2);
1715 ASSERT_EQ(1U, reverse_active_descendant.size());
1716 EXPECT_TRUE(base::Contains(reverse_active_descendant, 3));
1717
1719 update.root_id = 1;
1720 update.nodes.resize(1);
1721 update.nodes[0].id = 1;
1722 update.nodes[0].child_ids = {2};
1723 EXPECT_TRUE(tree.Unserialize(update));
1724
1725 reverse_active_descendant =
1726 tree.GetReverseRelations(ax::mojom::IntAttribute::kActivedescendantId, 2);
1727 ASSERT_EQ(0U, reverse_active_descendant.size());
1728}

◆ TEST() [127/215]

ui::TEST ( AXTreeTest  ,
DuplicateChildIdFails   
)

Definition at line 371 of file ax_tree_unittest.cc.

371 {
372 AXTreeUpdate initial_state;
373 initial_state.root_id = 1;
374 initial_state.nodes.resize(1);
375 initial_state.nodes[0].id = 1;
376 AXTree tree(initial_state);
377
378 // This should fail because a child id appears twice.
380 update.nodes.resize(2);
381 update.nodes[0].id = 1;
382 update.nodes[0].child_ids.push_back(2);
383 update.nodes[0].child_ids.push_back(2);
384 update.nodes[1].id = 2;
385 EXPECT_FALSE(tree.Unserialize(update));
386 ASSERT_EQ("Node 1 has duplicate child id 2", tree.error());
387}

◆ TEST() [128/215]

ui::TEST ( AXTreeTest  ,
EmptyNodeBoundsIsUnionOfChildren   
)

Definition at line 1301 of file ax_tree_unittest.cc.

1301 {
1302 AXTreeUpdate tree_update;
1303 tree_update.root_id = 1;
1304 tree_update.nodes.resize(4);
1305 tree_update.nodes[0].id = 1;
1306 tree_update.nodes[0].relative_bounds.bounds = gfx::RectF(0, 0, 800, 600);
1307 tree_update.nodes[0].child_ids.push_back(2);
1308 tree_update.nodes[1].id = 2;
1309 tree_update.nodes[1].relative_bounds.bounds =
1310 gfx::RectF(); // Deliberately empty.
1311 tree_update.nodes[1].child_ids.push_back(3);
1312 tree_update.nodes[1].child_ids.push_back(4);
1313 tree_update.nodes[2].id = 3;
1314 tree_update.nodes[2].relative_bounds.bounds = gfx::RectF(100, 10, 400, 20);
1315 tree_update.nodes[3].id = 4;
1316 tree_update.nodes[3].relative_bounds.bounds = gfx::RectF(200, 30, 400, 20);
1317
1318 AXTree tree(tree_update);
1319 EXPECT_EQ("(100, 10) size (500 x 40)", GetBoundsAsString(tree, 2));
1320}

◆ TEST() [129/215]

ui::TEST ( AXTreeTest  ,
EmptyNodeNotOffscreenEvenIfAllChildrenOffscreen   
)

Definition at line 1324 of file ax_tree_unittest.cc.

1324 {
1325 AXTreeUpdate tree_update;
1326 tree_update.root_id = 1;
1327 tree_update.nodes.resize(4);
1328 tree_update.nodes[0].id = 1;
1329 tree_update.nodes[0].relative_bounds.bounds = gfx::RectF(0, 0, 800, 600);
1330 tree_update.nodes[0].role = ax::mojom::Role::kRootWebArea;
1331 tree_update.nodes[0].AddBoolAttribute(
1333 tree_update.nodes[0].child_ids.push_back(2);
1334 tree_update.nodes[1].id = 2;
1335 tree_update.nodes[1].relative_bounds.bounds =
1336 gfx::RectF(); // Deliberately empty.
1337 tree_update.nodes[1].child_ids.push_back(3);
1338 tree_update.nodes[1].child_ids.push_back(4);
1339 // Both children are offscreen
1340 tree_update.nodes[2].id = 3;
1341 tree_update.nodes[2].relative_bounds.bounds = gfx::RectF(900, 10, 400, 20);
1342 tree_update.nodes[3].id = 4;
1343 tree_update.nodes[3].relative_bounds.bounds = gfx::RectF(1000, 30, 400, 20);
1344
1345 AXTree tree(tree_update);
1346 EXPECT_FALSE(IsNodeOffscreen(tree, 2));
1347 EXPECT_TRUE(IsNodeOffscreen(tree, 3));
1348 EXPECT_TRUE(IsNodeOffscreen(tree, 4));
1349}

◆ TEST() [130/215]

ui::TEST ( AXTreeTest  ,
GetBoundsBasic   
)

Definition at line 1284 of file ax_tree_unittest.cc.

1284 {
1285 AXTreeUpdate tree_update;
1286 tree_update.root_id = 1;
1287 tree_update.nodes.resize(2);
1288 tree_update.nodes[0].id = 1;
1289 tree_update.nodes[0].relative_bounds.bounds = gfx::RectF(0, 0, 800, 600);
1290 tree_update.nodes[0].child_ids.push_back(2);
1291 tree_update.nodes[1].id = 2;
1292 tree_update.nodes[1].relative_bounds.bounds = gfx::RectF(100, 10, 400, 300);
1293 AXTree tree(tree_update);
1294
1295 EXPECT_EQ("(0, 0) size (800 x 600)", GetBoundsAsString(tree, 1));
1296 EXPECT_EQ("(100, 10) size (400 x 300)", GetBoundsAsString(tree, 2));
1297}

◆ TEST() [131/215]

ui::TEST ( AXTreeTest  ,
GetBoundsCropsChildToRoot   
)

Definition at line 1482 of file ax_tree_unittest.cc.

1482 {
1483 AXTreeUpdate tree_update;
1484 tree_update.root_id = 1;
1485 tree_update.nodes.resize(5);
1486 tree_update.nodes[0].id = 1;
1487 tree_update.nodes[0].relative_bounds.bounds = gfx::RectF(0, 0, 800, 600);
1488 tree_update.nodes[0].AddBoolAttribute(
1490 tree_update.nodes[0].child_ids.push_back(2);
1491 tree_update.nodes[0].child_ids.push_back(3);
1492 tree_update.nodes[0].child_ids.push_back(4);
1493 tree_update.nodes[0].child_ids.push_back(5);
1494 // Cropped in the top left
1495 tree_update.nodes[1].id = 2;
1496 tree_update.nodes[1].relative_bounds.bounds =
1497 gfx::RectF(-100, -100, 150, 150);
1498 // Cropped in the bottom right
1499 tree_update.nodes[2].id = 3;
1500 tree_update.nodes[2].relative_bounds.bounds = gfx::RectF(700, 500, 150, 150);
1501 // Offscreen on the top
1502 tree_update.nodes[3].id = 4;
1503 tree_update.nodes[3].relative_bounds.bounds = gfx::RectF(50, -200, 150, 150);
1504 // Offscreen on the bottom
1505 tree_update.nodes[4].id = 5;
1506 tree_update.nodes[4].relative_bounds.bounds = gfx::RectF(50, 700, 150, 150);
1507
1508 AXTree tree(tree_update);
1509 EXPECT_EQ("(0, 0) size (50 x 50)", GetBoundsAsString(tree, 2));
1510 EXPECT_EQ("(700, 500) size (100 x 100)", GetBoundsAsString(tree, 3));
1511 EXPECT_EQ("(50, 0) size (150 x 1)", GetBoundsAsString(tree, 4));
1512 EXPECT_EQ("(50, 599) size (150 x 1)", GetBoundsAsString(tree, 5));
1513
1514 // Check the unclipped bounds are as expected.
1515 EXPECT_EQ("(-100, -100) size (150 x 150)",
1516 GetUnclippedBoundsAsString(tree, 2));
1517 EXPECT_EQ("(700, 500) size (150 x 150)", GetUnclippedBoundsAsString(tree, 3));
1518 EXPECT_EQ("(50, -200) size (150 x 150)", GetUnclippedBoundsAsString(tree, 4));
1519 EXPECT_EQ("(50, 700) size (150 x 150)", GetUnclippedBoundsAsString(tree, 5));
1520}

◆ TEST() [132/215]

ui::TEST ( AXTreeTest  ,
GetBoundsEmptyBoundsInheritsFromParent   
)

Definition at line 1455 of file ax_tree_unittest.cc.

1455 {
1456 AXTreeUpdate tree_update;
1457 tree_update.root_id = 1;
1458 tree_update.nodes.resize(3);
1459 tree_update.nodes[0].id = 1;
1460 tree_update.nodes[0].relative_bounds.bounds = gfx::RectF(0, 0, 800, 600);
1461 tree_update.nodes[1].AddBoolAttribute(
1463 tree_update.nodes[0].child_ids.push_back(2);
1464 tree_update.nodes[1].id = 2;
1465 tree_update.nodes[1].relative_bounds.bounds = gfx::RectF(300, 200, 100, 100);
1466 tree_update.nodes[1].child_ids.push_back(3);
1467 tree_update.nodes[2].id = 3;
1468 tree_update.nodes[2].relative_bounds.bounds = gfx::RectF();
1469
1470 AXTree tree(tree_update);
1471 EXPECT_EQ("(0, 0) size (800 x 600)", GetBoundsAsString(tree, 1));
1472 EXPECT_EQ("(300, 200) size (100 x 100)", GetBoundsAsString(tree, 2));
1473 EXPECT_EQ("(300, 200) size (100 x 100)", GetBoundsAsString(tree, 3));
1474 EXPECT_EQ("(0, 0) size (800 x 600)", GetUnclippedBoundsAsString(tree, 1));
1475 EXPECT_EQ("(300, 200) size (100 x 100)", GetUnclippedBoundsAsString(tree, 2));
1476 EXPECT_EQ("(300, 200) size (100 x 100)", GetUnclippedBoundsAsString(tree, 3));
1477 EXPECT_FALSE(IsNodeOffscreen(tree, 1));
1478 EXPECT_FALSE(IsNodeOffscreen(tree, 2));
1479 EXPECT_TRUE(IsNodeOffscreen(tree, 3));
1480}

◆ TEST() [133/215]

ui::TEST ( AXTreeTest  ,
GetBoundsOfNodeWithZeroSize   
)

Definition at line 1424 of file ax_tree_unittest.cc.

1424 {
1425 AXTreeUpdate tree_update;
1426 tree_update.root_id = 1;
1427 tree_update.nodes.resize(5);
1428 tree_update.nodes[0].id = 1;
1429 tree_update.nodes[0].relative_bounds.bounds = gfx::RectF(0, 0, 800, 600);
1430 tree_update.nodes[0].child_ids = {2};
1431 tree_update.nodes[1].id = 2;
1432 tree_update.nodes[1].relative_bounds.bounds = gfx::RectF(100, 100, 300, 200);
1433 tree_update.nodes[1].child_ids = {3, 4, 5};
1434
1435 // This child has relative coordinates and no offset and no size.
1436 tree_update.nodes[2].id = 3;
1437 tree_update.nodes[2].relative_bounds.offset_container_id = 2;
1438 tree_update.nodes[2].relative_bounds.bounds = gfx::RectF(0, 0, 0, 0);
1439
1440 // This child has relative coordinates and an offset, but no size.
1441 tree_update.nodes[3].id = 4;
1442 tree_update.nodes[3].relative_bounds.offset_container_id = 2;
1443 tree_update.nodes[3].relative_bounds.bounds = gfx::RectF(20, 20, 0, 0);
1444
1445 // This child has absolute coordinates, an offset, and no size.
1446 tree_update.nodes[4].id = 5;
1447 tree_update.nodes[4].relative_bounds.bounds = gfx::RectF(120, 120, 0, 0);
1448
1449 AXTree tree(tree_update);
1450 EXPECT_EQ("(100, 100) size (300 x 200)", GetBoundsAsString(tree, 3));
1451 EXPECT_EQ("(120, 120) size (280 x 180)", GetBoundsAsString(tree, 4));
1452 EXPECT_EQ("(120, 120) size (280 x 180)", GetBoundsAsString(tree, 5));
1453}

◆ TEST() [134/215]

ui::TEST ( AXTreeTest  ,
GetBoundsSetsOffscreenIfClipsChildren   
)

Definition at line 1522 of file ax_tree_unittest.cc.

1522 {
1523 AXTreeUpdate tree_update;
1524 tree_update.root_id = 1;
1525 tree_update.nodes.resize(5);
1526 tree_update.nodes[0].id = 1;
1527 tree_update.nodes[0].relative_bounds.bounds = gfx::RectF(0, 0, 800, 600);
1528 tree_update.nodes[0].AddBoolAttribute(
1530 tree_update.nodes[0].child_ids.push_back(2);
1531 tree_update.nodes[0].child_ids.push_back(3);
1532
1533 tree_update.nodes[1].id = 2;
1534 tree_update.nodes[1].relative_bounds.bounds = gfx::RectF(0, 0, 200, 200);
1535 tree_update.nodes[1].AddBoolAttribute(
1537 tree_update.nodes[1].child_ids.push_back(4);
1538
1539 tree_update.nodes[2].id = 3;
1540 tree_update.nodes[2].relative_bounds.bounds = gfx::RectF(0, 0, 200, 200);
1541 tree_update.nodes[2].child_ids.push_back(5);
1542
1543 // Clipped by its parent
1544 tree_update.nodes[3].id = 4;
1545 tree_update.nodes[3].relative_bounds.bounds = gfx::RectF(250, 250, 100, 100);
1546 tree_update.nodes[3].relative_bounds.offset_container_id = 2;
1547
1548 // Outside of its parent, but its parent does not clip children,
1549 // so it should not be offscreen.
1550 tree_update.nodes[4].id = 5;
1551 tree_update.nodes[4].relative_bounds.bounds = gfx::RectF(250, 250, 100, 100);
1552 tree_update.nodes[4].relative_bounds.offset_container_id = 3;
1553
1554 AXTree tree(tree_update);
1555 EXPECT_TRUE(IsNodeOffscreen(tree, 4));
1556 EXPECT_FALSE(IsNodeOffscreen(tree, 5));
1557}

◆ TEST() [135/215]

ui::TEST ( AXTreeTest  ,
GetBoundsUpdatesOffscreen   
)

Definition at line 1559 of file ax_tree_unittest.cc.

1559 {
1560 AXTreeUpdate tree_update;
1561 tree_update.root_id = 1;
1562 tree_update.nodes.resize(5);
1563 tree_update.nodes[0].id = 1;
1564 tree_update.nodes[0].relative_bounds.bounds = gfx::RectF(0, 0, 800, 600);
1565 tree_update.nodes[0].role = ax::mojom::Role::kRootWebArea;
1566 tree_update.nodes[0].AddBoolAttribute(
1568 tree_update.nodes[0].child_ids.push_back(2);
1569 tree_update.nodes[0].child_ids.push_back(3);
1570 tree_update.nodes[0].child_ids.push_back(4);
1571 tree_update.nodes[0].child_ids.push_back(5);
1572 // Fully onscreen
1573 tree_update.nodes[1].id = 2;
1574 tree_update.nodes[1].relative_bounds.bounds = gfx::RectF(10, 10, 150, 150);
1575 // Cropped in the bottom right
1576 tree_update.nodes[2].id = 3;
1577 tree_update.nodes[2].relative_bounds.bounds = gfx::RectF(700, 500, 150, 150);
1578 // Offscreen on the top
1579 tree_update.nodes[3].id = 4;
1580 tree_update.nodes[3].relative_bounds.bounds = gfx::RectF(50, -200, 150, 150);
1581 // Offscreen on the bottom
1582 tree_update.nodes[4].id = 5;
1583 tree_update.nodes[4].relative_bounds.bounds = gfx::RectF(50, 700, 150, 150);
1584
1585 AXTree tree(tree_update);
1586 EXPECT_FALSE(IsNodeOffscreen(tree, 2));
1587 EXPECT_FALSE(IsNodeOffscreen(tree, 3));
1588 EXPECT_TRUE(IsNodeOffscreen(tree, 4));
1589 EXPECT_TRUE(IsNodeOffscreen(tree, 5));
1590}

◆ TEST() [136/215]

ui::TEST ( AXTreeTest  ,
GetBoundsWithContainerId   
)

Definition at line 1379 of file ax_tree_unittest.cc.

1379 {
1380 AXTreeUpdate tree_update;
1381 tree_update.root_id = 1;
1382 tree_update.nodes.resize(4);
1383 tree_update.nodes[0].id = 1;
1384 tree_update.nodes[0].relative_bounds.bounds = gfx::RectF(0, 0, 800, 600);
1385 tree_update.nodes[0].child_ids.push_back(2);
1386 tree_update.nodes[1].id = 2;
1387 tree_update.nodes[1].relative_bounds.bounds = gfx::RectF(100, 50, 600, 500);
1388 tree_update.nodes[1].child_ids.push_back(3);
1389 tree_update.nodes[1].child_ids.push_back(4);
1390 tree_update.nodes[2].id = 3;
1391 tree_update.nodes[2].relative_bounds.offset_container_id = 2;
1392 tree_update.nodes[2].relative_bounds.bounds = gfx::RectF(20, 30, 50, 5);
1393 tree_update.nodes[3].id = 4;
1394 tree_update.nodes[3].relative_bounds.bounds = gfx::RectF(20, 30, 50, 5);
1395
1396 AXTree tree(tree_update);
1397 EXPECT_EQ("(120, 80) size (50 x 5)", GetBoundsAsString(tree, 3));
1398 EXPECT_EQ("(20, 30) size (50 x 5)", GetBoundsAsString(tree, 4));
1399}

◆ TEST() [137/215]

ui::TEST ( AXTreeTest  ,
GetBoundsWithScrolling   
)

Definition at line 1403 of file ax_tree_unittest.cc.

1403 {
1404 AXTreeUpdate tree_update;
1405 tree_update.root_id = 1;
1406 tree_update.nodes.resize(3);
1407 tree_update.nodes[0].id = 1;
1408 tree_update.nodes[0].relative_bounds.bounds = gfx::RectF(0, 0, 800, 600);
1409 tree_update.nodes[0].child_ids.push_back(2);
1410 tree_update.nodes[1].id = 2;
1411 tree_update.nodes[1].relative_bounds.bounds = gfx::RectF(100, 50, 600, 500);
1412 tree_update.nodes[1].AddIntAttribute(ax::mojom::IntAttribute::kScrollX, 5);
1413 tree_update.nodes[1].AddIntAttribute(ax::mojom::IntAttribute::kScrollY, 10);
1414 tree_update.nodes[1].child_ids.push_back(3);
1415 tree_update.nodes[2].id = 3;
1416 tree_update.nodes[2].relative_bounds.offset_container_id = 2;
1417 tree_update.nodes[2].relative_bounds.bounds = gfx::RectF(20, 30, 50, 5);
1418
1419 AXTree tree(tree_update);
1420 EXPECT_EQ("(115, 70) size (50 x 5)", GetBoundsAsString(tree, 3));
1421}

◆ TEST() [138/215]

ui::TEST ( AXTreeTest  ,
GetBoundsWithTransform   
)

Definition at line 1352 of file ax_tree_unittest.cc.

1352 {
1353 AXTreeUpdate tree_update;
1354 tree_update.root_id = 1;
1355 tree_update.nodes.resize(3);
1356 tree_update.nodes[0].id = 1;
1357 tree_update.nodes[0].relative_bounds.bounds = gfx::RectF(0, 0, 400, 300);
1358 tree_update.nodes[0].relative_bounds.transform =
1359 std::make_unique<gfx::Transform>();
1360 tree_update.nodes[0].relative_bounds.transform->Scale(2.0, 2.0);
1361 tree_update.nodes[0].child_ids.push_back(2);
1362 tree_update.nodes[0].child_ids.push_back(3);
1363 tree_update.nodes[1].id = 2;
1364 tree_update.nodes[1].relative_bounds.bounds = gfx::RectF(20, 10, 50, 5);
1365 tree_update.nodes[2].id = 3;
1366 tree_update.nodes[2].relative_bounds.bounds = gfx::RectF(20, 30, 50, 5);
1367 tree_update.nodes[2].relative_bounds.transform =
1368 std::make_unique<gfx::Transform>();
1369 tree_update.nodes[2].relative_bounds.transform->Scale(2.0, 2.0);
1370
1371 AXTree tree(tree_update);
1372 EXPECT_EQ("(0, 0) size (800 x 600)", GetBoundsAsString(tree, 1));
1373 EXPECT_EQ("(40, 20) size (100 x 10)", GetBoundsAsString(tree, 2));
1374 EXPECT_EQ("(80, 120) size (200 x 20)", GetBoundsAsString(tree, 3));
1375}

◆ TEST() [139/215]

ui::TEST ( AXTreeTest  ,
GetChildrenOrSiblings   
)

Definition at line 2975 of file ax_tree_unittest.cc.

2975 {
2976 // 1
2977 // ├── 2
2978 // │ └── 5
2979 // ├── 3
2980 // └── 4
2981 AXTreeUpdate tree_update;
2982 tree_update.root_id = 1;
2983 tree_update.nodes.resize(5);
2984 tree_update.nodes[0].id = 1;
2985 tree_update.nodes[0].child_ids = {2, 3, 4};
2986 tree_update.nodes[1].id = 2;
2987 tree_update.nodes[1].child_ids = {5};
2988 tree_update.nodes[2].id = 3;
2989 tree_update.nodes[3].id = 4;
2990 tree_update.nodes[4].id = 5;
2991
2992 AXTree tree(tree_update);
2993
2994 EXPECT_EQ(tree.GetFromId(2), tree.GetFromId(1)->GetFirstChild());
2995 EXPECT_EQ(tree.GetFromId(5), tree.GetFromId(2)->GetFirstChild());
2996 EXPECT_EQ(nullptr, tree.GetFromId(3)->GetFirstChild());
2997 EXPECT_EQ(nullptr, tree.GetFromId(4)->GetFirstChild());
2998 EXPECT_EQ(nullptr, tree.GetFromId(5)->GetFirstChild());
2999
3000 EXPECT_EQ(tree.GetFromId(4), tree.GetFromId(1)->GetLastChild());
3001 EXPECT_EQ(tree.GetFromId(5), tree.GetFromId(2)->GetLastChild());
3002 EXPECT_EQ(nullptr, tree.GetFromId(3)->GetLastChild());
3003 EXPECT_EQ(nullptr, tree.GetFromId(4)->GetLastChild());
3004 EXPECT_EQ(nullptr, tree.GetFromId(5)->GetLastChild());
3005
3006 EXPECT_EQ(nullptr, tree.GetFromId(1)->GetPreviousSibling());
3007 EXPECT_EQ(nullptr, tree.GetFromId(2)->GetPreviousSibling());
3008 EXPECT_EQ(tree.GetFromId(2), tree.GetFromId(3)->GetPreviousSibling());
3009 EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(4)->GetPreviousSibling());
3010 EXPECT_EQ(nullptr, tree.GetFromId(5)->GetPreviousSibling());
3011
3012 EXPECT_EQ(nullptr, tree.GetFromId(1)->GetNextSibling());
3013 EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(2)->GetNextSibling());
3014 EXPECT_EQ(tree.GetFromId(4), tree.GetFromId(3)->GetNextSibling());
3015 EXPECT_EQ(nullptr, tree.GetFromId(4)->GetNextSibling());
3016 EXPECT_EQ(nullptr, tree.GetFromId(5)->GetNextSibling());
3017}

◆ TEST() [140/215]

ui::TEST ( AXTreeTest  ,
GetSiblingsNoIgnored   
)

Definition at line 2490 of file ax_tree_unittest.cc.

2490 {
2491 // Since this tree base::contains no ignored nodes, PreviousSibling and
2492 // NextSibling are equivalent to their unignored counterparts.
2493 //
2494 // 1
2495 // ├── 2
2496 // │ └── 4
2497 // └── 3
2498 AXTreeUpdate tree_update;
2499 tree_update.root_id = 1;
2500 tree_update.nodes.resize(4);
2501 tree_update.nodes[0].id = 1;
2502 tree_update.nodes[0].child_ids = {2, 3};
2503 tree_update.nodes[1].id = 2;
2504 tree_update.nodes[1].child_ids = {4};
2505 tree_update.nodes[2].id = 3;
2506 tree_update.nodes[3].id = 4;
2507
2508 AXTree tree(tree_update);
2509
2510 EXPECT_EQ(nullptr, tree.GetFromId(1)->GetPreviousSibling());
2511 EXPECT_EQ(nullptr, tree.GetFromId(1)->GetPreviousUnignoredSibling());
2512 EXPECT_EQ(nullptr, tree.GetFromId(1)->GetNextSibling());
2513 EXPECT_EQ(nullptr, tree.GetFromId(1)->GetNextUnignoredSibling());
2514
2515 EXPECT_EQ(nullptr, tree.GetFromId(2)->GetPreviousSibling());
2516 EXPECT_EQ(nullptr, tree.GetFromId(2)->GetPreviousUnignoredSibling());
2517 EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(2)->GetNextSibling());
2518 EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(2)->GetNextUnignoredSibling());
2519
2520 EXPECT_EQ(tree.GetFromId(2), tree.GetFromId(3)->GetPreviousSibling());
2521 EXPECT_EQ(tree.GetFromId(2),
2522 tree.GetFromId(3)->GetPreviousUnignoredSibling());
2523 EXPECT_EQ(nullptr, tree.GetFromId(3)->GetNextSibling());
2524 EXPECT_EQ(nullptr, tree.GetFromId(3)->GetNextUnignoredSibling());
2525
2526 EXPECT_EQ(nullptr, tree.GetFromId(4)->GetPreviousSibling());
2527 EXPECT_EQ(nullptr, tree.GetFromId(4)->GetPreviousUnignoredSibling());
2528 EXPECT_EQ(nullptr, tree.GetFromId(4)->GetNextSibling());
2529 EXPECT_EQ(nullptr, tree.GetFromId(4)->GetNextUnignoredSibling());
2530}

◆ TEST() [141/215]

ui::TEST ( AXTreeTest  ,
GetUnignoredSiblingIgnoredParentIrrelevant   
)

Definition at line 2660 of file ax_tree_unittest.cc.

2660 {
2661 // An ignored parent is not relevant unless the search would need to continue
2662 // up through it.
2663 //
2664 // (i) => node is ignored.
2665 //
2666 // 1(i)
2667 // ├── 2
2668 // └── 3
2669 AXTreeUpdate tree_update;
2670 tree_update.root_id = 1;
2671 tree_update.nodes.resize(3);
2672 tree_update.nodes[0].id = 1;
2673 tree_update.nodes[0].AddState(ax::mojom::State::kIgnored);
2674 tree_update.nodes[0].child_ids = {2, 3};
2675 tree_update.nodes[1].id = 2;
2676 tree_update.nodes[2].id = 3;
2677
2678 AXTree tree(tree_update);
2679
2680 // Node 2 and 3 are each other's unignored siblings, the parent's ignored
2681 // status is not relevant for this search.
2682 EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(2)->GetNextUnignoredSibling());
2683 EXPECT_EQ(tree.GetFromId(2),
2684 tree.GetFromId(3)->GetPreviousUnignoredSibling());
2685}

◆ TEST() [142/215]

ui::TEST ( AXTreeTest  ,
GetUnignoredSiblingsAllIgnored   
)

Definition at line 2687 of file ax_tree_unittest.cc.

2687 {
2688 // Test termination when all nodes, including the root node, are ignored.
2689 //
2690 // (i) => node is ignored.
2691 //
2692 // 1(i)
2693 // └── 2(i)
2694 AXTreeUpdate tree_update;
2695 tree_update.root_id = 1;
2696 tree_update.nodes.resize(2);
2697 tree_update.nodes[0].id = 1;
2698 tree_update.nodes[0].AddState(ax::mojom::State::kIgnored);
2699 tree_update.nodes[0].child_ids = {2};
2700 tree_update.nodes[1].id = 2;
2701 tree_update.nodes[1].AddState(ax::mojom::State::kIgnored);
2702
2703 AXTree tree(tree_update);
2704
2705 EXPECT_EQ(nullptr, tree.GetFromId(1)->GetPreviousUnignoredSibling());
2706 EXPECT_EQ(nullptr, tree.GetFromId(1)->GetNextUnignoredSibling());
2707 EXPECT_EQ(nullptr, tree.GetFromId(2)->GetPreviousUnignoredSibling());
2708 EXPECT_EQ(nullptr, tree.GetFromId(2)->GetNextUnignoredSibling());
2709}

◆ TEST() [143/215]

ui::TEST ( AXTreeTest  ,
GetUnignoredSiblingsChildrenPromoted   
)

Definition at line 2532 of file ax_tree_unittest.cc.

2532 {
2533 // An ignored node has its' children considered as though they were promoted
2534 // to their parents place.
2535 //
2536 // (i) => node is ignored.
2537 //
2538 // 1
2539 // ├── 2(i)
2540 // │ ├── 4
2541 // │ └── 5
2542 // └── 3
2543 AXTreeUpdate tree_update;
2544 tree_update.root_id = 1;
2545 tree_update.nodes.resize(5);
2546 tree_update.nodes[0].id = 1;
2547 tree_update.nodes[0].child_ids = {2, 3};
2548 tree_update.nodes[1].id = 2;
2549 tree_update.nodes[1].AddState(ax::mojom::State::kIgnored);
2550 tree_update.nodes[1].child_ids = {4, 5};
2551 tree_update.nodes[2].id = 3;
2552 tree_update.nodes[3].id = 4;
2553 tree_update.nodes[4].id = 5;
2554
2555 AXTree tree(tree_update);
2556
2557 // Root node has no siblings.
2558 EXPECT_EQ(nullptr, tree.GetFromId(1)->GetPreviousUnignoredSibling());
2559 EXPECT_EQ(nullptr, tree.GetFromId(2)->GetPreviousUnignoredSibling());
2560
2561 // Node 2's view of siblings:
2562 // literal tree: null <-- [2(i)] --> 3
2563 // unignored tree: null <-- [2(i)] --> 3
2564 EXPECT_EQ(nullptr, tree.GetFromId(2)->GetPreviousSibling());
2565 EXPECT_EQ(nullptr, tree.GetFromId(2)->GetPreviousUnignoredSibling());
2566 EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(2)->GetNextSibling());
2567 EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(2)->GetNextUnignoredSibling());
2568
2569 // Node 3's view of siblings:
2570 // literal tree: 2(i) <-- [3] --> null
2571 // unignored tree: 5 <-- [4] --> null
2572 EXPECT_EQ(tree.GetFromId(2), tree.GetFromId(3)->GetPreviousSibling());
2573 EXPECT_EQ(tree.GetFromId(5),
2574 tree.GetFromId(3)->GetPreviousUnignoredSibling());
2575 EXPECT_EQ(nullptr, tree.GetFromId(3)->GetNextSibling());
2576 EXPECT_EQ(nullptr, tree.GetFromId(3)->GetNextUnignoredSibling());
2577
2578 // Node 4's view of siblings:
2579 // literal tree: null <-- [4] --> 5
2580 // unignored tree: null <-- [4] --> 5
2581 EXPECT_EQ(nullptr, tree.GetFromId(4)->GetPreviousSibling());
2582 EXPECT_EQ(nullptr, tree.GetFromId(4)->GetPreviousUnignoredSibling());
2583 EXPECT_EQ(tree.GetFromId(5), tree.GetFromId(4)->GetNextSibling());
2584 EXPECT_EQ(tree.GetFromId(5), tree.GetFromId(4)->GetNextUnignoredSibling());
2585
2586 // Node 5's view of siblings:
2587 // literal tree: 4 <-- [5] --> null
2588 // unignored tree: 4 <-- [5] --> 3
2589 EXPECT_EQ(tree.GetFromId(4), tree.GetFromId(5)->GetPreviousSibling());
2590 EXPECT_EQ(tree.GetFromId(4),
2591 tree.GetFromId(5)->GetPreviousUnignoredSibling());
2592 EXPECT_EQ(nullptr, tree.GetFromId(5)->GetNextSibling());
2593 EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(5)->GetNextUnignoredSibling());
2594}

◆ TEST() [144/215]

ui::TEST ( AXTreeTest  ,
GetUnignoredSiblingsIgnoredChildSkipped   
)

Definition at line 2596 of file ax_tree_unittest.cc.

2596 {
2597 // Ignored children of ignored parents are skipped over.
2598 //
2599 // (i) => node is ignored.
2600 //
2601 // 1
2602 // ├── 2(i)
2603 // │ ├── 4
2604 // │ └── 5(i)
2605 // └── 3
2606 AXTreeUpdate tree_update;
2607 tree_update.root_id = 1;
2608 tree_update.nodes.resize(5);
2609 tree_update.nodes[0].id = 1;
2610 tree_update.nodes[0].child_ids = {2, 3};
2611 tree_update.nodes[1].id = 2;
2612 tree_update.nodes[1].AddState(ax::mojom::State::kIgnored);
2613 tree_update.nodes[1].child_ids = {4, 5};
2614 tree_update.nodes[2].id = 3;
2615 tree_update.nodes[3].id = 4;
2616 tree_update.nodes[4].id = 5;
2617 tree_update.nodes[4].AddState(ax::mojom::State::kIgnored);
2618
2619 AXTree tree(tree_update);
2620
2621 // Root node has no siblings.
2622 EXPECT_EQ(nullptr, tree.GetFromId(1)->GetPreviousUnignoredSibling());
2623 EXPECT_EQ(nullptr, tree.GetFromId(1)->GetNextUnignoredSibling());
2624
2625 // Node 2's view of siblings:
2626 // literal tree: null <-- [2(i)] --> 3
2627 // unignored tree: null <-- [2(i)] --> 3
2628 EXPECT_EQ(nullptr, tree.GetFromId(2)->GetPreviousSibling());
2629 EXPECT_EQ(nullptr, tree.GetFromId(2)->GetPreviousUnignoredSibling());
2630 EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(2)->GetNextSibling());
2631 EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(2)->GetNextUnignoredSibling());
2632
2633 // Node 3's view of siblings:
2634 // literal tree: 2(i) <-- [3] --> null
2635 // unignored tree: 4 <-- [3] --> null
2636 EXPECT_EQ(tree.GetFromId(2), tree.GetFromId(3)->GetPreviousSibling());
2637 EXPECT_EQ(tree.GetFromId(4),
2638 tree.GetFromId(3)->GetPreviousUnignoredSibling());
2639 EXPECT_EQ(nullptr, tree.GetFromId(3)->GetNextSibling());
2640 EXPECT_EQ(nullptr, tree.GetFromId(3)->GetNextUnignoredSibling());
2641
2642 // Node 4's view of siblings:
2643 // literal tree: null <-- [4] --> 5(i)
2644 // unignored tree: null <-- [4] --> 3
2645 EXPECT_EQ(nullptr, tree.GetFromId(4)->GetPreviousSibling());
2646 EXPECT_EQ(nullptr, tree.GetFromId(4)->GetPreviousUnignoredSibling());
2647 EXPECT_EQ(tree.GetFromId(5), tree.GetFromId(4)->GetNextSibling());
2648 EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(4)->GetNextUnignoredSibling());
2649
2650 // Node 5's view of siblings:
2651 // literal tree: 4 <-- [5(i)] --> null
2652 // unignored tree: 4 <-- [5(i)] --> 3
2653 EXPECT_EQ(tree.GetFromId(4), tree.GetFromId(5)->GetPreviousSibling());
2654 EXPECT_EQ(tree.GetFromId(4),
2655 tree.GetFromId(5)->GetPreviousUnignoredSibling());
2656 EXPECT_EQ(nullptr, tree.GetFromId(5)->GetNextSibling());
2657 EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(5)->GetNextUnignoredSibling());
2658}

◆ TEST() [145/215]

ui::TEST ( AXTreeTest  ,
GetUnignoredSiblingsNestedIgnored   
)

Definition at line 2711 of file ax_tree_unittest.cc.

2711 {
2712 // Test promotion of children through multiple layers of ignored parents.
2713 // (i) => node is ignored.
2714 //
2715 // 1
2716 // ├── 2
2717 // ├── 3(i)
2718 // │ └── 5(i)
2719 // │ └── 6
2720 // └── 4
2721 AXTreeUpdate tree_update;
2722 tree_update.root_id = 1;
2723 tree_update.nodes.resize(6);
2724 tree_update.nodes[0].id = 1;
2725 tree_update.nodes[0].child_ids = {2, 3, 4};
2726 tree_update.nodes[1].id = 2;
2727 tree_update.nodes[2].id = 3;
2728 tree_update.nodes[2].AddState(ax::mojom::State::kIgnored);
2729 tree_update.nodes[2].child_ids = {5};
2730 tree_update.nodes[3].id = 4;
2731 tree_update.nodes[4].id = 5;
2732 tree_update.nodes[4].AddState(ax::mojom::State::kIgnored);
2733 tree_update.nodes[4].child_ids = {6};
2734 tree_update.nodes[5].id = 6;
2735
2736 AXTree tree(tree_update);
2737
2738 EXPECT_EQ(nullptr, tree.GetFromId(1)->GetPreviousUnignoredSibling());
2739
2740 const AXNode* node2 = tree.GetFromId(2);
2741 const AXNode* node3 = tree.GetFromId(3);
2742 const AXNode* node4 = tree.GetFromId(4);
2743 const AXNode* node5 = tree.GetFromId(5);
2744 const AXNode* node6 = tree.GetFromId(6);
2745
2746 ASSERT_NE(nullptr, node2);
2747 ASSERT_NE(nullptr, node3);
2748 ASSERT_NE(nullptr, node4);
2749 ASSERT_NE(nullptr, node5);
2750 ASSERT_NE(nullptr, node6);
2751
2752 // Node 2's view of siblings:
2753 // literal tree: null <-- [2] --> 3
2754 // unignored tree: null <-- [2] --> 6
2755 EXPECT_EQ(nullptr, node2->GetPreviousSibling());
2756 EXPECT_EQ(nullptr, node2->GetPreviousUnignoredSibling());
2757 EXPECT_EQ(node3, node2->GetNextSibling());
2758 EXPECT_EQ(node6, node2->GetNextUnignoredSibling());
2759
2760 // Node 3's view of siblings:
2761 // literal tree: 2 <-- [3(i)] --> 4
2762 // unignored tree: 2 <-- [3(i)] --> 4
2763 EXPECT_EQ(node2, node3->GetPreviousSibling());
2764 EXPECT_EQ(node2, node3->GetPreviousUnignoredSibling());
2765 EXPECT_EQ(node4, node3->GetNextSibling());
2766 EXPECT_EQ(node4, node3->GetNextUnignoredSibling());
2767
2768 // Node 4's view of siblings:
2769 // literal tree: 3 <-- [4] --> null
2770 // unignored tree: 6 <-- [4] --> null
2771 EXPECT_EQ(node3, node4->GetPreviousSibling());
2772 EXPECT_EQ(node6, node4->GetPreviousUnignoredSibling());
2773 EXPECT_EQ(nullptr, node4->GetNextSibling());
2774 EXPECT_EQ(nullptr, node4->GetNextUnignoredSibling());
2775
2776 // Node 5's view of siblings:
2777 // literal tree: null <-- [5(i)] --> null
2778 // unignored tree: 2 <-- [5(i)] --> 4
2779 EXPECT_EQ(nullptr, node5->GetPreviousSibling());
2780 EXPECT_EQ(node2, node5->GetPreviousUnignoredSibling());
2781 EXPECT_EQ(nullptr, node5->GetNextSibling());
2782 EXPECT_EQ(node4, node5->GetNextUnignoredSibling());
2783
2784 // Node 6's view of siblings:
2785 // literal tree: null <-- [6] --> null
2786 // unignored tree: 2 <-- [6] --> 4
2787 EXPECT_EQ(nullptr, node6->GetPreviousSibling());
2788 EXPECT_EQ(node2, node6->GetPreviousUnignoredSibling());
2789 EXPECT_EQ(nullptr, node6->GetNextSibling());
2790 EXPECT_EQ(node4, node6->GetNextUnignoredSibling());
2791}

◆ TEST() [146/215]

ui::TEST ( AXTreeTest  ,
ImplicitAttributeDelete   
)

Definition at line 814 of file ax_tree_unittest.cc.

814 {
815 // This test covers the case where an AXTreeUpdate includes a node without
816 // mentioning one of that node's attributes, this should cause a delete of any
817 // unmentioned attribute that was previously set on the node.
818
819 AXTreeUpdate initial_state;
820 initial_state.root_id = 1;
821 initial_state.nodes.resize(1);
822 initial_state.nodes[0].id = 1;
823 initial_state.nodes[0].SetName("Node 1 name");
824 AXTree tree(initial_state);
825
826 EXPECT_NE(tree.GetFromId(1), nullptr);
827 EXPECT_EQ(
828 tree.GetFromId(1)->GetStringAttribute(ax::mojom::StringAttribute::kName),
829 "Node 1 name");
830
831 // Perform a no-op update of node 1 but omit any mention of the name
832 // attribute. This should delete the name attribute.
834 update.nodes.resize(1);
835 update.nodes[0].id = 1;
836 ASSERT_TRUE(tree.Unserialize(update));
837
838 // Check that the name attribute is no longer present.
839 EXPECT_NE(tree.GetFromId(1), nullptr);
840 EXPECT_FALSE(
841 tree.GetFromId(1)->HasStringAttribute(ax::mojom::StringAttribute::kName));
842}

◆ TEST() [147/215]

ui::TEST ( AXTreeTest  ,
ImplicitChildrenDelete   
)

Definition at line 664 of file ax_tree_unittest.cc.

664 {
665 // This test covers the case where an AXTreeUpdate includes a node without
666 // mentioning that node's children, this should cause a delete of those child
667 // nodes.
668
669 // Setup initial tree state
670 // Tree:
671 // 1
672 // 2 3
673 AXTreeUpdate initial_state;
674 initial_state.root_id = 1;
675 initial_state.nodes.resize(3);
676 initial_state.nodes[0].id = 1;
677 initial_state.nodes[0].child_ids.resize(2);
678 initial_state.nodes[0].child_ids[0] = 2;
679 initial_state.nodes[0].child_ids[1] = 3;
680 initial_state.nodes[1].id = 2;
681 initial_state.nodes[2].id = 3;
682 AXTree tree(initial_state);
683
684 EXPECT_NE(tree.GetFromId(1), nullptr);
685 EXPECT_NE(tree.GetFromId(2), nullptr);
686 EXPECT_NE(tree.GetFromId(3), nullptr);
687
688 // Perform a no-op update of node 1 but omit any mention of its children. This
689 // should delete all of the node's children.
691 update.nodes.resize(1);
692 update.nodes[0].id = 1;
693
694 ASSERT_TRUE(tree.Unserialize(update));
695
696 // Check that nodes 2 and 3 have been deleted.
697 EXPECT_NE(tree.GetFromId(1), nullptr);
698 EXPECT_EQ(tree.GetFromId(2), nullptr);
699 EXPECT_EQ(tree.GetFromId(3), nullptr);
700}

◆ TEST() [148/215]

ui::TEST ( AXTreeTest  ,
IndexInParentAfterReorder   
)

Definition at line 702 of file ax_tree_unittest.cc.

702 {
703 // This test covers the case where an AXTreeUpdate includes
704 // reordered children. The unignored index in parent
705 // values should be updated.
706
707 // Setup initial tree state.
708 // Tree:
709 // 1
710 // 2 3 4
711 AXTreeUpdate initial_state;
712 initial_state.root_id = 1;
713 initial_state.nodes.resize(4);
714 initial_state.nodes[0].id = 1;
715 initial_state.nodes[0].child_ids.resize(3);
716 initial_state.nodes[0].child_ids[0] = 2;
717 initial_state.nodes[0].child_ids[1] = 3;
718 initial_state.nodes[0].child_ids[2] = 4;
719 initial_state.nodes[1].id = 2;
720 initial_state.nodes[2].id = 3;
721 initial_state.nodes[3].id = 4;
722 AXTree tree(initial_state);
723
724 // Index in parent correct.
725 EXPECT_EQ(0U, tree.GetFromId(2)->GetUnignoredIndexInParent());
726 EXPECT_EQ(1U, tree.GetFromId(3)->GetUnignoredIndexInParent());
727 EXPECT_EQ(2U, tree.GetFromId(4)->GetUnignoredIndexInParent());
728
729 // Perform an update where we reorder children to [ 4 3 2 ]
731 update.nodes.resize(4);
732 update.root_id = 1;
733 update.nodes[0].id = 1;
734 update.nodes[0].child_ids.resize(3);
735 update.nodes[0].child_ids[0] = 4;
736 update.nodes[0].child_ids[1] = 3;
737 update.nodes[0].child_ids[2] = 2;
738 update.nodes[1].id = 2;
739 update.nodes[2].id = 3;
740 update.nodes[3].id = 4;
741
742 ASSERT_TRUE(tree.Unserialize(update));
743
744 // Index in parent should have changed as well.
745 EXPECT_EQ(0U, tree.GetFromId(4)->GetUnignoredIndexInParent());
746 EXPECT_EQ(1U, tree.GetFromId(3)->GetUnignoredIndexInParent());
747 EXPECT_EQ(2U, tree.GetFromId(2)->GetUnignoredIndexInParent());
748}

◆ TEST() [149/215]

ui::TEST ( AXTreeTest  ,
IndexInParentAfterReorderIgnoredNode   
)

Definition at line 750 of file ax_tree_unittest.cc.

750 {
751 // This test covers another case where an AXTreeUpdate includes
752 // reordered children. If one of the reordered nodes is ignored, its
753 // children's unignored index in parent should also be updated.
754
755 // Setup initial tree state.
756 // Tree:
757 // 1
758 // 2 3i 4
759 // 5 6
760 AXTreeUpdate initial_state;
761 initial_state.root_id = 1;
762 initial_state.nodes.resize(6);
763 initial_state.nodes[0].id = 1;
764 initial_state.nodes[0].child_ids.resize(3);
765 initial_state.nodes[0].child_ids[0] = 2;
766 initial_state.nodes[0].child_ids[1] = 3;
767 initial_state.nodes[0].child_ids[2] = 4;
768 initial_state.nodes[1].id = 2;
769 initial_state.nodes[2].id = 3;
770 initial_state.nodes[2].AddState(ax::mojom::State::kIgnored);
771 initial_state.nodes[2].child_ids.resize(2);
772 initial_state.nodes[2].child_ids[0] = 5;
773 initial_state.nodes[2].child_ids[1] = 6;
774 initial_state.nodes[3].id = 4;
775 initial_state.nodes[4].id = 5;
776 initial_state.nodes[5].id = 6;
777 AXTree tree(initial_state);
778
779 // Index in parent correct.
780 EXPECT_EQ(0U, tree.GetFromId(2)->GetUnignoredIndexInParent());
781 EXPECT_EQ(1U, tree.GetFromId(5)->GetUnignoredIndexInParent());
782 EXPECT_EQ(2U, tree.GetFromId(6)->GetUnignoredIndexInParent());
783 EXPECT_EQ(3U, tree.GetFromId(4)->GetUnignoredIndexInParent());
784
785 // Perform an update where we reorder children to [ 3i 2 4 ]. The
786 // unignored index in parent for the children of the ignored node (3) should
787 // be updated.
789 update.root_id = 1;
790 update.nodes.resize(6);
791 update.nodes[0].id = 1;
792 update.nodes[0].child_ids.resize(3);
793 update.nodes[0].child_ids[0] = 3;
794 update.nodes[0].child_ids[1] = 2;
795 update.nodes[0].child_ids[2] = 4;
796 update.nodes[1].id = 2;
797 update.nodes[2].id = 3;
798 update.nodes[2].AddState(ax::mojom::State::kIgnored);
799 update.nodes[2].child_ids.resize(2);
800 update.nodes[2].child_ids[0] = 5;
801 update.nodes[2].child_ids[1] = 6;
802 update.nodes[3].id = 4;
803 update.nodes[4].id = 5;
804 update.nodes[5].id = 6;
805
806 ASSERT_TRUE(tree.Unserialize(update));
807
808 EXPECT_EQ(2U, tree.GetFromId(2)->GetUnignoredIndexInParent());
809 EXPECT_EQ(0U, tree.GetFromId(5)->GetUnignoredIndexInParent());
810 EXPECT_EQ(1U, tree.GetFromId(6)->GetUnignoredIndexInParent());
811 EXPECT_EQ(3U, tree.GetFromId(4)->GetUnignoredIndexInParent());
812}

◆ TEST() [150/215]

ui::TEST ( AXTreeTest  ,
IntListChangeCallbacks   
)

Definition at line 1221 of file ax_tree_unittest.cc.

1221 {
1222 std::vector<int32_t> one;
1223 one.push_back(1);
1224
1225 std::vector<int32_t> two;
1226 two.push_back(2);
1227 two.push_back(2);
1228
1229 std::vector<int32_t> three;
1230 three.push_back(3);
1231
1232 AXTreeUpdate initial_state;
1233 initial_state.root_id = 1;
1234 initial_state.nodes.resize(1);
1235 initial_state.nodes[0].id = 1;
1236 initial_state.nodes[0].AddIntListAttribute(
1238 initial_state.nodes[0].AddIntListAttribute(
1240 AXTree tree(initial_state);
1241
1242 TestAXTreeObserver test_observer(&tree);
1243
1244 // Change existing attributes.
1245 AXTreeUpdate update0;
1246 update0.root_id = 1;
1247 update0.nodes.resize(1);
1248 update0.nodes[0].id = 1;
1249 update0.nodes[0].AddIntListAttribute(
1251 update0.nodes[0].AddIntListAttribute(
1253 EXPECT_TRUE(tree.Unserialize(update0));
1254
1255 const std::vector<std::string>& change_log =
1256 test_observer.attribute_change_log();
1257 ASSERT_EQ(2U, change_log.size());
1258 EXPECT_EQ("controlsIds changed from 1 to 2,2", change_log[0]);
1259 EXPECT_EQ("radioGroupIds changed from 2,2 to 3", change_log[1]);
1260
1261 TestAXTreeObserver test_observer2(&tree);
1262
1263 // Add and remove attributes.
1264 AXTreeUpdate update1;
1265 update1.root_id = 1;
1266 update1.nodes.resize(1);
1267 update1.nodes[0].id = 1;
1268 update1.nodes[0].AddIntListAttribute(
1270 update1.nodes[0].AddIntListAttribute(ax::mojom::IntListAttribute::kFlowtoIds,
1271 three);
1272 EXPECT_TRUE(tree.Unserialize(update1));
1273
1274 const std::vector<std::string>& change_log2 =
1275 test_observer2.attribute_change_log();
1276 ASSERT_EQ(3U, change_log2.size());
1277 EXPECT_EQ("controlsIds changed from 2,2 to ", change_log2[0]);
1278 EXPECT_EQ("radioGroupIds changed from 3 to 2,2", change_log2[1]);
1279 EXPECT_EQ("flowtoIds changed from to 3", change_log2[2]);
1280}

◆ TEST() [151/215]

ui::TEST ( AXTreeTest  ,
IntListReverseRelations   
)

Definition at line 1658 of file ax_tree_unittest.cc.

1658 {
1659 std::vector<int32_t> node_two;
1660 node_two.push_back(2);
1661
1662 std::vector<int32_t> nodes_two_three;
1663 nodes_two_three.push_back(2);
1664 nodes_two_three.push_back(3);
1665
1666 AXTreeUpdate initial_state;
1667 initial_state.root_id = 1;
1668 initial_state.nodes.resize(3);
1669 initial_state.nodes[0].id = 1;
1670 initial_state.nodes[0].AddIntListAttribute(
1672 initial_state.nodes[0].child_ids.push_back(2);
1673 initial_state.nodes[0].child_ids.push_back(3);
1674 initial_state.nodes[1].id = 2;
1675 initial_state.nodes[2].id = 3;
1676
1677 AXTree tree(initial_state);
1678
1679 auto reverse_labelled_by =
1680 tree.GetReverseRelations(ax::mojom::IntListAttribute::kLabelledbyIds, 2);
1681 ASSERT_EQ(1U, reverse_labelled_by.size());
1682 EXPECT_TRUE(base::Contains(reverse_labelled_by, 1));
1683
1684 reverse_labelled_by =
1685 tree.GetReverseRelations(ax::mojom::IntListAttribute::kLabelledbyIds, 3);
1686 ASSERT_EQ(0U, reverse_labelled_by.size());
1687
1688 // Change existing attributes.
1689 AXTreeUpdate update = initial_state;
1690 update.nodes[0].intlist_attributes.clear();
1691 update.nodes[0].AddIntListAttribute(
1693 EXPECT_TRUE(tree.Unserialize(update));
1694
1695 reverse_labelled_by =
1696 tree.GetReverseRelations(ax::mojom::IntListAttribute::kLabelledbyIds, 3);
1697 ASSERT_EQ(1U, reverse_labelled_by.size());
1698 EXPECT_TRUE(base::Contains(reverse_labelled_by, 1));
1699}

◆ TEST() [152/215]

ui::TEST ( AXTreeTest  ,
IntReverseRelations   
)

Definition at line 1592 of file ax_tree_unittest.cc.

1592 {
1593 AXTreeUpdate initial_state;
1594 initial_state.root_id = 1;
1595 initial_state.nodes.resize(4);
1596 initial_state.nodes[0].id = 1;
1597 initial_state.nodes[0].AddIntAttribute(
1599 initial_state.nodes[0].child_ids.push_back(2);
1600 initial_state.nodes[0].child_ids.push_back(3);
1601 initial_state.nodes[0].child_ids.push_back(4);
1602 initial_state.nodes[1].id = 2;
1603 initial_state.nodes[2].id = 3;
1604 initial_state.nodes[2].AddIntAttribute(ax::mojom::IntAttribute::kMemberOfId,
1605 1);
1606 initial_state.nodes[3].id = 4;
1607 initial_state.nodes[3].AddIntAttribute(ax::mojom::IntAttribute::kMemberOfId,
1608 1);
1609 AXTree tree(initial_state);
1610
1611 auto reverse_active_descendant =
1612 tree.GetReverseRelations(ax::mojom::IntAttribute::kActivedescendantId, 2);
1613 ASSERT_EQ(1U, reverse_active_descendant.size());
1614 EXPECT_TRUE(base::Contains(reverse_active_descendant, 1));
1615
1616 reverse_active_descendant =
1617 tree.GetReverseRelations(ax::mojom::IntAttribute::kActivedescendantId, 1);
1618 ASSERT_EQ(0U, reverse_active_descendant.size());
1619
1620 auto reverse_errormessage =
1621 tree.GetReverseRelations(ax::mojom::IntAttribute::kErrormessageId, 1);
1622 ASSERT_EQ(0U, reverse_errormessage.size());
1623
1624 auto reverse_member_of =
1625 tree.GetReverseRelations(ax::mojom::IntAttribute::kMemberOfId, 1);
1626 ASSERT_EQ(2U, reverse_member_of.size());
1627 EXPECT_TRUE(base::Contains(reverse_member_of, 3));
1628 EXPECT_TRUE(base::Contains(reverse_member_of, 4));
1629
1630 AXTreeUpdate update = initial_state;
1631 update.nodes.resize(5);
1632 update.nodes[0].int_attributes.clear();
1634 5);
1635 update.nodes[0].child_ids.push_back(5);
1636 update.nodes[2].int_attributes.clear();
1637 update.nodes[4].id = 5;
1638 update.nodes[4].AddIntAttribute(ax::mojom::IntAttribute::kMemberOfId, 1);
1639
1640 EXPECT_TRUE(tree.Unserialize(update));
1641
1642 reverse_active_descendant =
1643 tree.GetReverseRelations(ax::mojom::IntAttribute::kActivedescendantId, 2);
1644 ASSERT_EQ(0U, reverse_active_descendant.size());
1645
1646 reverse_active_descendant =
1647 tree.GetReverseRelations(ax::mojom::IntAttribute::kActivedescendantId, 5);
1648 ASSERT_EQ(1U, reverse_active_descendant.size());
1649 EXPECT_TRUE(base::Contains(reverse_active_descendant, 1));
1650
1651 reverse_member_of =
1652 tree.GetReverseRelations(ax::mojom::IntAttribute::kMemberOfId, 1);
1653 ASSERT_EQ(2U, reverse_member_of.size());
1654 EXPECT_TRUE(base::Contains(reverse_member_of, 4));
1655 EXPECT_TRUE(base::Contains(reverse_member_of, 5));
1656}

◆ TEST() [153/215]

ui::TEST ( AXTreeTest  ,
InvalidReparentingFails   
)

Definition at line 389 of file ax_tree_unittest.cc.

389 {
390 AXTreeUpdate initial_state;
391 initial_state.root_id = 1;
392 initial_state.nodes.resize(3);
393 initial_state.nodes[0].id = 1;
394 initial_state.nodes[0].child_ids.push_back(2);
395 initial_state.nodes[1].id = 2;
396 initial_state.nodes[1].child_ids.push_back(3);
397 initial_state.nodes[2].id = 3;
398
399 AXTree tree(initial_state);
400
401 // This should fail because node 3 is reparented from node 2 to node 1
402 // without deleting node 1's subtree first.
404 update.nodes.resize(3);
405 update.nodes[0].id = 1;
406 update.nodes[0].child_ids.push_back(3);
407 update.nodes[0].child_ids.push_back(2);
408 update.nodes[1].id = 2;
409 update.nodes[2].id = 3;
410 EXPECT_FALSE(tree.Unserialize(update));
411 ASSERT_EQ("Node 3 is not marked for destruction, would be reparented to 1",
412 tree.error());
413}

◆ TEST() [154/215]

ui::TEST ( AXTreeTest  ,
LeaveOrphanedDeletedSubtreeFails   
)

Definition at line 333 of file ax_tree_unittest.cc.

333 {
334 AXTreeUpdate initial_state;
335 initial_state.root_id = 1;
336 initial_state.nodes.resize(3);
337 initial_state.nodes[0].id = 1;
338 initial_state.nodes[0].child_ids.push_back(2);
339 initial_state.nodes[0].child_ids.push_back(3);
340 initial_state.nodes[1].id = 2;
341 initial_state.nodes[2].id = 3;
342 AXTree tree(initial_state);
343
344 // This should fail because we delete a subtree rooted at id=2
345 // but never update it.
347 update.node_id_to_clear = 2;
348 update.nodes.resize(1);
349 update.nodes[0].id = 3;
350 EXPECT_FALSE(tree.Unserialize(update));
351 ASSERT_EQ("Nodes left pending by the update: 2", tree.error());
352}

◆ TEST() [155/215]

ui::TEST ( AXTreeTest  ,
LeaveOrphanedNewChildFails   
)

Definition at line 354 of file ax_tree_unittest.cc.

354 {
355 AXTreeUpdate initial_state;
356 initial_state.root_id = 1;
357 initial_state.nodes.resize(1);
358 initial_state.nodes[0].id = 1;
359 AXTree tree(initial_state);
360
361 // This should fail because we add a new child to the root node
362 // but never update it.
364 update.nodes.resize(1);
365 update.nodes[0].id = 1;
366 update.nodes[0].child_ids.push_back(2);
367 EXPECT_FALSE(tree.Unserialize(update));
368 ASSERT_EQ("Nodes left pending by the update: 2", tree.error());
369}

◆ TEST() [156/215]

ui::TEST ( AXTreeTest  ,
MultipleIgnoredChangesDoesNotBreakCache   
)

Definition at line 949 of file ax_tree_unittest.cc.

949 {
950 AXTreeUpdate initial_state;
951 initial_state.root_id = 1;
952 initial_state.nodes.resize(3);
953 initial_state.nodes[0].id = 1;
954 initial_state.nodes[0].child_ids.push_back(2);
955
956 initial_state.nodes[1].id = 2;
957 initial_state.nodes[1].AddState(ax::mojom::State::kIgnored);
958 initial_state.nodes[1].child_ids.push_back(3);
959
960 initial_state.nodes[2].id = 3;
961
962 AXTree tree(initial_state);
963 TestAXTreeObserver test_observer(&tree);
964 EXPECT_EQ(1u, tree.GetFromId(2)->GetUnignoredChildCount());
965
967 update.nodes.resize(2);
968 update.nodes[0].id = 3;
969 update.nodes[0].AddState(ax::mojom::State::kIgnored);
970
971 update.nodes[1].id = 2;
972 update.nodes[1].child_ids.push_back(3);
973
974 EXPECT_TRUE(tree.Unserialize(update)) << tree.error();
975 EXPECT_EQ(0u, tree.GetFromId(2)->GetUnignoredChildCount());
976 EXPECT_FALSE(tree.GetFromId(2)->data().HasState(ax::mojom::State::kIgnored));
977 EXPECT_TRUE(tree.GetFromId(3)->data().HasState(ax::mojom::State::kIgnored));
978}

◆ TEST() [157/215]

ui::TEST ( AXTreeTest  ,
NodeToClearUpdatesParentUnignoredCount   
)

Definition at line 980 of file ax_tree_unittest.cc.

980 {
981 AXTreeUpdate initial_state;
982 initial_state.root_id = 1;
983 initial_state.nodes.resize(4);
984 initial_state.nodes[0].id = 1;
985 initial_state.nodes[0].child_ids.push_back(2);
986 initial_state.nodes[1].id = 2;
987 initial_state.nodes[1].AddState(ax::mojom::State::kIgnored);
988 initial_state.nodes[1].child_ids.push_back(3);
989 initial_state.nodes[1].child_ids.push_back(4);
990 initial_state.nodes[2].id = 3;
991 initial_state.nodes[3].id = 4;
992
993 AXTree tree(initial_state);
994 EXPECT_EQ(2u, tree.GetFromId(1)->GetUnignoredChildCount());
995 EXPECT_EQ(2u, tree.GetFromId(2)->GetUnignoredChildCount());
996
998 update.nodes.resize(1);
999 update.node_id_to_clear = 2;
1000 update.root_id = 1;
1001 update.nodes[0] = initial_state.nodes[1];
1002 update.nodes[0].state = 0;
1003 update.nodes[0].child_ids.resize(0);
1004 EXPECT_TRUE(tree.Unserialize(update)) << tree.error();
1005
1006 EXPECT_EQ(1u, tree.GetFromId(1)->GetUnignoredChildCount());
1007}

◆ TEST() [158/215]

ui::TEST ( AXTreeTest  ,
NoReparentingIfOnlyRemovedAndChangedNotReAdded   
)

Definition at line 464 of file ax_tree_unittest.cc.

464 {
466 root.id = 1;
467 AXNodeData child1;
468 child1.id = 2;
469 AXNodeData child2;
470 child2.id = 3;
471
472 root.child_ids = {child1.id};
473 child1.child_ids = {child2.id};
474
475 AXTreeUpdate initial_state;
476 initial_state.root_id = root.id;
477 initial_state.nodes = {root, child1, child2};
478
479 AXTree tree(initial_state);
480
481 // Change existing attributes.
483 update.nodes.resize(2);
484 update.nodes[0].id = 2;
486 3);
487 update.nodes[1].id = 1;
488
489 TestAXTreeObserver test_observer(&tree);
490 EXPECT_TRUE(tree.Unserialize(update)) << tree.error();
491
492 EXPECT_EQ(2U, test_observer.deleted_ids().size());
493 EXPECT_EQ(2U, test_observer.subtree_deleted_ids().size());
494 EXPECT_EQ(0U, test_observer.created_ids().size());
495
496 EXPECT_EQ(0U, test_observer.node_creation_finished_ids().size());
497 EXPECT_EQ(0U, test_observer.subtree_creation_finished_ids().size());
498 EXPECT_EQ(0U, test_observer.node_will_be_reparented_ids().size());
499 EXPECT_EQ(2U, test_observer.node_will_be_deleted_ids().size());
500 EXPECT_EQ(0U, test_observer.subtree_will_be_reparented_ids().size());
501 EXPECT_EQ(0U, test_observer.node_reparented_ids().size());
502 EXPECT_EQ(0U, test_observer.node_reparented_finished_ids().size());
503 EXPECT_EQ(0U, test_observer.subtree_reparented_finished_ids().size());
504
505 EXPECT_FALSE(test_observer.root_changed());
506 EXPECT_FALSE(test_observer.tree_data_changed());
507}

◆ TEST() [159/215]

ui::TEST ( AXTreeTest  ,
NoReparentingIfRemovedMultipleTimesAndNotInFinalTree   
)

Definition at line 512 of file ax_tree_unittest.cc.

512 {
513 AXTreeUpdate initial_state;
514 initial_state.root_id = 1;
515 initial_state.nodes.resize(4);
516 initial_state.nodes[0].id = 1;
517 initial_state.nodes[0].child_ids = {2, 4};
518 initial_state.nodes[1].id = 2;
519 initial_state.nodes[1].child_ids = {3};
520 initial_state.nodes[2].id = 3;
521 initial_state.nodes[3].id = 4;
522
523 AXTree tree(initial_state);
524
526 update.nodes.resize(4);
527 // Delete AXID 3
528 update.nodes[0].id = 2;
529 // Reparent AXID 3 onto AXID 4
530 update.nodes[1].id = 4;
531 update.nodes[1].child_ids = {3};
532 update.nodes[2].id = 3;
533 // Delete AXID 3
534 update.nodes[3].id = 4;
535
536 TestAXTreeObserver test_observer(&tree);
537 ASSERT_TRUE(tree.Unserialize(update)) << tree.error();
538
539 EXPECT_EQ(1U, test_observer.deleted_ids().size());
540 EXPECT_EQ(1U, test_observer.subtree_deleted_ids().size());
541 EXPECT_EQ(0U, test_observer.created_ids().size());
542
543 EXPECT_EQ(0U, test_observer.node_creation_finished_ids().size());
544 EXPECT_EQ(0U, test_observer.subtree_creation_finished_ids().size());
545 EXPECT_EQ(0U, test_observer.node_will_be_reparented_ids().size());
546 EXPECT_EQ(1U, test_observer.node_will_be_deleted_ids().size());
547 EXPECT_EQ(0U, test_observer.subtree_will_be_reparented_ids().size());
548 EXPECT_EQ(0U, test_observer.node_reparented_ids().size());
549 EXPECT_EQ(0U, test_observer.node_reparented_finished_ids().size());
550 EXPECT_EQ(0U, test_observer.subtree_reparented_finished_ids().size());
551
552 EXPECT_FALSE(test_observer.root_changed());
553 EXPECT_FALSE(test_observer.tree_data_changed());
554}

◆ TEST() [160/215]

ui::TEST ( AXTreeTest  ,
NoReparentingOfRootIfNoNewRoot   
)

Definition at line 415 of file ax_tree_unittest.cc.

415 {
417 root.id = 1;
418 AXNodeData child1;
419 child1.id = 2;
420 AXNodeData child2;
421 child2.id = 3;
422
423 root.child_ids = {child1.id};
424 child1.child_ids = {child2.id};
425
426 AXTreeUpdate initial_state;
427 initial_state.root_id = root.id;
428 initial_state.nodes = {root, child1, child2};
429
430 AXTree tree(initial_state);
431
432 // Update the root but don't change it by reparenting |child2| to be a child
433 // of the root.
434 root.child_ids = {child1.id, child2.id};
435 child1.child_ids = {};
436
438 update.root_id = root.id;
439 update.node_id_to_clear = root.id;
440 update.nodes = {root, child1, child2};
441
442 TestAXTreeObserver test_observer(&tree);
443 ASSERT_TRUE(tree.Unserialize(update));
444
445 EXPECT_EQ(0U, test_observer.deleted_ids().size());
446 EXPECT_EQ(0U, test_observer.subtree_deleted_ids().size());
447 EXPECT_EQ(0U, test_observer.created_ids().size());
448
449 EXPECT_EQ(0U, test_observer.node_creation_finished_ids().size());
450 EXPECT_EQ(0U, test_observer.subtree_creation_finished_ids().size());
451 EXPECT_EQ(0U, test_observer.node_reparented_finished_ids().size());
452
453 ASSERT_EQ(2U, test_observer.subtree_reparented_finished_ids().size());
454 EXPECT_EQ(child1.id, test_observer.subtree_reparented_finished_ids()[0]);
455 EXPECT_EQ(child2.id, test_observer.subtree_reparented_finished_ids()[1]);
456
457 ASSERT_EQ(1U, test_observer.change_finished_ids().size());
458 EXPECT_EQ(root.id, test_observer.change_finished_ids()[0]);
459
460 EXPECT_FALSE(test_observer.root_changed());
461 EXPECT_FALSE(test_observer.tree_data_changed());
462}

◆ TEST() [161/215]

ui::TEST ( AXTreeTest  ,
NullUnignoredChildren   
)

Definition at line 1961 of file ax_tree_unittest.cc.

1961 {
1962 AXTreeUpdate tree_update;
1963 tree_update.root_id = 1;
1964 tree_update.nodes.resize(3);
1965 tree_update.nodes[0].id = 1;
1966 tree_update.nodes[0].child_ids = {2, 3};
1967 tree_update.nodes[1].id = 2;
1968 tree_update.nodes[1].AddState(ax::mojom::State::kIgnored);
1969 tree_update.nodes[2].id = 3;
1970 tree_update.nodes[2].AddState(ax::mojom::State::kIgnored);
1971 AXTree tree(tree_update);
1972
1973 AXNode* root = tree.root();
1974 EXPECT_EQ(2u, root->children().size());
1975 EXPECT_EQ(0u, root->GetUnignoredChildCount());
1976 EXPECT_EQ(nullptr, root->GetUnignoredChildAtIndex(0));
1977 EXPECT_EQ(nullptr, root->GetUnignoredChildAtIndex(1));
1978}

◆ TEST() [162/215]

ui::TEST ( AXTreeTest  ,
OnNodeHasBeenDeleted   
)

Definition at line 4393 of file ax_tree_unittest.cc.

4393 {
4394 AXTreeUpdate initial_state;
4395
4396 initial_state.root_id = 1;
4397 initial_state.nodes.resize(6);
4398 initial_state.nodes[0].id = 1;
4399 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
4400 initial_state.nodes[0].child_ids = {2};
4401 initial_state.nodes[1].id = 2;
4402 initial_state.nodes[1].role = ax::mojom::Role::kButton;
4403 initial_state.nodes[1].child_ids = {3, 4};
4404 initial_state.nodes[2].id = 3;
4405 initial_state.nodes[2].role = ax::mojom::Role::kCheckBox;
4406 initial_state.nodes[3].id = 4;
4407 initial_state.nodes[3].role = ax::mojom::Role::kStaticText;
4408 initial_state.nodes[3].child_ids = {5, 6};
4409 initial_state.nodes[4].id = 5;
4410 initial_state.nodes[4].role = ax::mojom::Role::kInlineTextBox;
4411 initial_state.nodes[5].id = 6;
4412 initial_state.nodes[5].role = ax::mojom::Role::kInlineTextBox;
4413
4414 AXTree tree(initial_state);
4415
4417 update.nodes.resize(2);
4418 update.nodes[0] = initial_state.nodes[1];
4419 update.nodes[0].child_ids = {4};
4420 update.nodes[1] = initial_state.nodes[3];
4421 update.nodes[1].child_ids = {};
4422
4423 TestAXTreeObserver test_observer(&tree);
4424 ASSERT_TRUE(tree.Unserialize(update));
4425
4426 EXPECT_EQ(3U, test_observer.deleted_ids().size());
4427 EXPECT_EQ(3, test_observer.deleted_ids()[0]);
4428 EXPECT_EQ(5, test_observer.deleted_ids()[1]);
4429 EXPECT_EQ(6, test_observer.deleted_ids()[2]);
4430
4431 // Verify that the nodes we intend to delete in the update are actually
4432 // absent from the tree.
4433 for (auto id : test_observer.deleted_ids()) {
4434 SCOPED_TRACE(testing::Message()
4435 << "Node with id=" << id << ", should not exist in the tree");
4436 EXPECT_EQ(nullptr, tree.GetFromId(id));
4437 }
4438}

◆ TEST() [163/215]

ui::TEST ( AXTreeTest  ,
OnNodeWillBeDeletedHasValidUnignoredParent   
)

Definition at line 4365 of file ax_tree_unittest.cc.

4365 {
4366 AXTreeUpdate initial_state;
4367 initial_state.root_id = 1;
4368 initial_state.nodes.resize(3);
4369 initial_state.nodes[0].id = 1;
4370 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
4371 initial_state.nodes[0].child_ids = {2};
4372 initial_state.nodes[1].id = 2;
4373 initial_state.nodes[1].role = ax::mojom::Role::kGenericContainer;
4374 initial_state.nodes[1].child_ids = {3};
4375 initial_state.nodes[2].id = 3;
4376 initial_state.nodes[2].role = ax::mojom::Role::kGenericContainer;
4377 AXTree tree(initial_state);
4378
4379 AXTreeUpdate tree_update;
4380 tree_update.nodes.resize(1);
4381 // Remove child from node:2, and add State::kIgnored
4382 tree_update.nodes[0] = initial_state.nodes[1];
4383 tree_update.nodes[0].AddState(ax::mojom::State::kIgnored);
4384 tree_update.nodes[0].child_ids.clear();
4385
4386 // Before node:3 is deleted, the unignored parent is node:2.
4387 // Assert that this is the case in |OnNodeWillBeDeleted|.
4388 TestAXTreeObserver test_observer(&tree);
4389 test_observer.unignored_parent_id_before_node_deleted = 2;
4390 ASSERT_TRUE(tree.Unserialize(tree_update));
4391}

◆ TEST() [164/215]

ui::TEST ( AXTreeTest  ,
OrderedSetReportsSetSize   
)

Definition at line 3497 of file ax_tree_unittest.cc.

3497 {
3498 AXTreeUpdate tree_update;
3499 tree_update.root_id = 1;
3500 tree_update.nodes.resize(12);
3501 tree_update.nodes[0].id = 1;
3502 tree_update.nodes[0].role = ax::mojom::Role::kList; // SetSize = 3
3503 tree_update.nodes[0].child_ids = {2, 3, 4, 7, 8, 9, 12};
3504 tree_update.nodes[1].id = 2;
3505 tree_update.nodes[1].role = ax::mojom::Role::kListItem; // 1 of 3
3506 tree_update.nodes[2].id = 3;
3507 tree_update.nodes[2].role = ax::mojom::Role::kListItem; // 2 of 3
3508 tree_update.nodes[3].id = 4;
3509 tree_update.nodes[3].role = ax::mojom::Role::kList; // SetSize = 2
3510 tree_update.nodes[3].child_ids = {5, 6};
3511 tree_update.nodes[4].id = 5;
3512 tree_update.nodes[4].role = ax::mojom::Role::kListItem; // 1 of 2
3513 tree_update.nodes[5].id = 6;
3514 tree_update.nodes[5].role = ax::mojom::Role::kListItem; // 2 of 2
3515 tree_update.nodes[6].id = 7;
3516 tree_update.nodes[6].role = ax::mojom::Role::kListItem; // 3 of 3
3517 tree_update.nodes[7].id = 8;
3518 tree_update.nodes[7].role = ax::mojom::Role::kList; // SetSize = 0
3519 tree_update.nodes[8].id = 9;
3520 tree_update.nodes[8].role =
3521 ax::mojom::Role::kList; // SetSize = 1 because only 1
3522 // item whose role matches
3523 tree_update.nodes[8].child_ids = {10, 11};
3524 tree_update.nodes[9].id = 10;
3525 tree_update.nodes[9].role = ax::mojom::Role::kArticle;
3526 tree_update.nodes[10].id = 11;
3527 tree_update.nodes[10].role = ax::mojom::Role::kListItem;
3528 tree_update.nodes[11].id = 12;
3529 tree_update.nodes[11].role = ax::mojom::Role::kList;
3530 tree_update.nodes[11].AddIntAttribute(ax::mojom::IntAttribute::kSetSize, 5);
3531 AXTree tree(tree_update);
3532
3533 AXNode* outer_list = tree.GetFromId(1);
3534 EXPECT_FALSE(outer_list->GetPosInSet());
3535 EXPECT_OPTIONAL_EQ(3, outer_list->GetSetSize());
3536 AXNode* outer_list_item1 = tree.GetFromId(2);
3537 EXPECT_OPTIONAL_EQ(1, outer_list_item1->GetPosInSet());
3538 EXPECT_OPTIONAL_EQ(3, outer_list_item1->GetSetSize());
3539 AXNode* outer_list_item2 = tree.GetFromId(3);
3540 EXPECT_OPTIONAL_EQ(2, outer_list_item2->GetPosInSet());
3541 EXPECT_OPTIONAL_EQ(3, outer_list_item2->GetSetSize());
3542 AXNode* outer_list_item3 = tree.GetFromId(7);
3543 EXPECT_OPTIONAL_EQ(3, outer_list_item3->GetPosInSet());
3544 EXPECT_OPTIONAL_EQ(3, outer_list_item3->GetSetSize());
3545
3546 AXNode* inner_list1 = tree.GetFromId(4);
3547 EXPECT_FALSE(inner_list1->GetPosInSet());
3548 EXPECT_OPTIONAL_EQ(2, inner_list1->GetSetSize());
3549 AXNode* inner_list1_item1 = tree.GetFromId(5);
3550 EXPECT_OPTIONAL_EQ(1, inner_list1_item1->GetPosInSet());
3551 EXPECT_OPTIONAL_EQ(2, inner_list1_item1->GetSetSize());
3552 AXNode* inner_list1_item2 = tree.GetFromId(6);
3553 EXPECT_OPTIONAL_EQ(2, inner_list1_item2->GetPosInSet());
3554 EXPECT_OPTIONAL_EQ(2, inner_list1_item2->GetSetSize());
3555
3556 AXNode* inner_list2 = tree.GetFromId(8); // Empty list
3557 EXPECT_FALSE(inner_list2->GetPosInSet());
3558 EXPECT_OPTIONAL_EQ(0, inner_list2->GetSetSize());
3559
3560 AXNode* inner_list3 = tree.GetFromId(9);
3561 EXPECT_FALSE(inner_list3->GetPosInSet());
3562 // Only 1 item whose role matches.
3563 EXPECT_OPTIONAL_EQ(1, inner_list3->GetSetSize());
3564 AXNode* inner_list3_article1 = tree.GetFromId(10);
3565 EXPECT_FALSE(inner_list3_article1->GetPosInSet());
3566 EXPECT_FALSE(inner_list3_article1->GetSetSize());
3567 AXNode* inner_list3_item1 = tree.GetFromId(11);
3568 EXPECT_OPTIONAL_EQ(1, inner_list3_item1->GetPosInSet());
3569 EXPECT_OPTIONAL_EQ(1, inner_list3_item1->GetSetSize());
3570
3571 AXNode* inner_list4 = tree.GetFromId(12);
3572 EXPECT_FALSE(inner_list4->GetPosInSet());
3573 // Even though list is empty, kSetSize attribute was set, so it takes
3574 // precedence
3575 EXPECT_OPTIONAL_EQ(5, inner_list4->GetSetSize());
3576}
#define EXPECT_OPTIONAL_EQ(expected, actual)

◆ TEST() [165/215]

ui::TEST ( AXTreeTest  ,
PosInSetDecreasing   
)

Definition at line 3296 of file ax_tree_unittest.cc.

3296 {
3297 AXTreeUpdate tree_update;
3298 tree_update.root_id = 1;
3299 tree_update.nodes.resize(4);
3300 tree_update.nodes[0].id = 1;
3301 tree_update.nodes[0].role = ax::mojom::Role::kList;
3302 tree_update.nodes[0].child_ids = {2, 3, 4};
3303 tree_update.nodes[1].id = 2;
3304 tree_update.nodes[1].role = ax::mojom::Role::kListItem; // 1 of 8
3305 tree_update.nodes[2].id = 3;
3306 tree_update.nodes[2].role = ax::mojom::Role::kListItem; // 7 of 8
3307 tree_update.nodes[2].AddIntAttribute(ax::mojom::IntAttribute::kPosInSet, 7);
3308 tree_update.nodes[3].id = 4;
3309 tree_update.nodes[3].role = ax::mojom::Role::kListItem; // 8 of 8
3310 tree_update.nodes[3].AddIntAttribute(ax::mojom::IntAttribute::kPosInSet, 3);
3311 AXTree tree(tree_update);
3312
3313 AXNode* item1 = tree.GetFromId(2);
3314 EXPECT_OPTIONAL_EQ(1, item1->GetPosInSet());
3315 EXPECT_OPTIONAL_EQ(8, item1->GetSetSize());
3316 AXNode* item2 = tree.GetFromId(3);
3317 EXPECT_OPTIONAL_EQ(7, item2->GetPosInSet());
3318 EXPECT_OPTIONAL_EQ(8, item2->GetSetSize());
3319 AXNode* item3 = tree.GetFromId(4);
3320 EXPECT_OPTIONAL_EQ(8, item3->GetPosInSet());
3321 EXPECT_OPTIONAL_EQ(8, item3->GetSetSize());
3322}

◆ TEST() [166/215]

ui::TEST ( AXTreeTest  ,
PosInSetDuplicates   
)

Definition at line 3327 of file ax_tree_unittest.cc.

3327 {
3328 AXTreeUpdate tree_update;
3329 tree_update.root_id = 1;
3330 tree_update.nodes.resize(4);
3331 tree_update.nodes[0].id = 1;
3332 tree_update.nodes[0].role = ax::mojom::Role::kList;
3333 tree_update.nodes[0].child_ids = {2, 3, 4};
3334 tree_update.nodes[1].id = 2;
3335 tree_update.nodes[1].role = ax::mojom::Role::kListItem; // 6 of 8
3336 tree_update.nodes[1].AddIntAttribute(ax::mojom::IntAttribute::kPosInSet, 6);
3337 tree_update.nodes[2].id = 3;
3338 tree_update.nodes[2].role = ax::mojom::Role::kListItem; // 7 of 8
3339 tree_update.nodes[2].AddIntAttribute(ax::mojom::IntAttribute::kPosInSet, 6);
3340 tree_update.nodes[3].id = 4;
3341 tree_update.nodes[3].role = ax::mojom::Role::kListItem; // 8 of 8
3342 tree_update.nodes[3].AddIntAttribute(ax::mojom::IntAttribute::kPosInSet, 7);
3343 AXTree tree(tree_update);
3344
3345 AXNode* item1 = tree.GetFromId(2);
3346 EXPECT_OPTIONAL_EQ(6, item1->GetPosInSet());
3347 EXPECT_OPTIONAL_EQ(8, item1->GetSetSize());
3348 AXNode* item2 = tree.GetFromId(3);
3349 EXPECT_OPTIONAL_EQ(7, item2->GetPosInSet());
3350 EXPECT_OPTIONAL_EQ(8, item2->GetSetSize());
3351 AXNode* item3 = tree.GetFromId(4);
3352 EXPECT_OPTIONAL_EQ(8, item3->GetPosInSet());
3353 EXPECT_OPTIONAL_EQ(8, item3->GetSetSize());
3354}

◆ TEST() [167/215]

ui::TEST ( AXTreeTest  ,
PosInSetMissing   
)

Definition at line 3194 of file ax_tree_unittest.cc.

3194 {
3195 AXTreeUpdate tree_update;
3196 tree_update.root_id = 1;
3197 tree_update.nodes.resize(4);
3198 tree_update.nodes[0].id = 1;
3199 tree_update.nodes[0].role = ax::mojom::Role::kList;
3200 tree_update.nodes[0].child_ids = {2, 3, 4};
3201 tree_update.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kSetSize, 20);
3202 tree_update.nodes[1].id = 2;
3203 tree_update.nodes[1].role = ax::mojom::Role::kListItem;
3204 tree_update.nodes[2].id = 3;
3205 tree_update.nodes[2].role = ax::mojom::Role::kListItem;
3206 tree_update.nodes[2].AddIntAttribute(ax::mojom::IntAttribute::kPosInSet, 13);
3207 tree_update.nodes[3].id = 4;
3208 tree_update.nodes[3].role = ax::mojom::Role::kListItem;
3209 AXTree tree(tree_update);
3210
3211 // Item1 should have pos of 12, since item2 is assigned a pos of 13.
3212 AXNode* item1 = tree.GetFromId(2);
3213 EXPECT_OPTIONAL_EQ(1, item1->GetPosInSet());
3214 EXPECT_OPTIONAL_EQ(20, item1->GetSetSize());
3215 AXNode* item2 = tree.GetFromId(3);
3216 EXPECT_OPTIONAL_EQ(13, item2->GetPosInSet());
3217 EXPECT_OPTIONAL_EQ(20, item2->GetSetSize());
3218 // Item2 should have pos of 14, since item2 is assigned a pos of 13.
3219 AXNode* item3 = tree.GetFromId(4);
3220 EXPECT_OPTIONAL_EQ(14, item3->GetPosInSet());
3221 EXPECT_OPTIONAL_EQ(20, item3->GetSetSize());
3222}

◆ TEST() [168/215]

ui::TEST ( AXTreeTest  ,
ReparentIfRemovedMultipleTimesButExistsInFinalTree   
)

Definition at line 559 of file ax_tree_unittest.cc.

559 {
560 AXTreeUpdate initial_state;
561 initial_state.root_id = 1;
562 initial_state.nodes.resize(4);
563 initial_state.nodes[0].id = 1;
564 initial_state.nodes[0].child_ids = {2, 4};
565 initial_state.nodes[1].id = 2;
566 initial_state.nodes[1].child_ids = {3};
567 initial_state.nodes[2].id = 3;
568 initial_state.nodes[3].id = 4;
569
570 AXTree tree(initial_state);
571
573 update.nodes.resize(6);
574 // Delete AXID 3
575 update.nodes[0].id = 2;
576 // Reparent AXID 3 onto AXID 4
577 update.nodes[1].id = 4;
578 update.nodes[1].child_ids = {3};
579 update.nodes[2].id = 3;
580 // Delete AXID 3
581 update.nodes[3].id = 4;
582 // Reparent AXID 3 onto AXID 2
583 update.nodes[4].id = 2;
584 update.nodes[4].child_ids = {3};
585 update.nodes[5].id = 3;
586
587 TestAXTreeObserver test_observer(&tree);
588 ASSERT_TRUE(tree.Unserialize(update)) << tree.error();
589
590 EXPECT_EQ(0U, test_observer.deleted_ids().size());
591 EXPECT_EQ(0U, test_observer.subtree_deleted_ids().size());
592 EXPECT_EQ(0U, test_observer.created_ids().size());
593
594 EXPECT_EQ(0U, test_observer.node_creation_finished_ids().size());
595 EXPECT_EQ(0U, test_observer.subtree_creation_finished_ids().size());
596 EXPECT_EQ(1U, test_observer.node_will_be_reparented_ids().size());
597 EXPECT_EQ(0U, test_observer.node_will_be_deleted_ids().size());
598 EXPECT_EQ(1U, test_observer.subtree_will_be_reparented_ids().size());
599 EXPECT_EQ(1U, test_observer.node_reparented_ids().size());
600 EXPECT_EQ(0U, test_observer.node_reparented_finished_ids().size());
601 EXPECT_EQ(1U, test_observer.subtree_reparented_finished_ids().size());
602
603 EXPECT_FALSE(test_observer.root_changed());
604 EXPECT_FALSE(test_observer.tree_data_changed());
605}

◆ TEST() [169/215]

ui::TEST ( AXTreeTest  ,
ReparentingDoesNotTriggerNodeCreated   
)

Definition at line 918 of file ax_tree_unittest.cc.

918 {
919 AXTreeUpdate initial_state;
920 initial_state.root_id = 1;
921 initial_state.nodes.resize(3);
922 initial_state.nodes[0].id = 1;
923 initial_state.nodes[0].child_ids.push_back(2);
924 initial_state.nodes[1].id = 2;
925 initial_state.nodes[1].child_ids.push_back(3);
926 initial_state.nodes[2].id = 3;
927
928 AXTree tree(initial_state);
929 TestAXTreeObserver test_observer(&tree);
930
932 update.nodes.resize(2);
933 update.node_id_to_clear = 2;
934 update.root_id = 1;
935 update.nodes[0].id = 1;
936 update.nodes[0].child_ids.push_back(3);
937 update.nodes[1].id = 3;
938 EXPECT_TRUE(tree.Unserialize(update)) << tree.error();
939 std::vector<int> created = test_observer.node_creation_finished_ids();
940 std::vector<int> subtree_reparented =
941 test_observer.subtree_reparented_finished_ids();
942 std::vector<int> node_reparented =
943 test_observer.node_reparented_finished_ids();
944 ASSERT_FALSE(base::Contains(created, 3));
945 ASSERT_TRUE(base::Contains(subtree_reparented, 3));
946 ASSERT_FALSE(base::Contains(node_reparented, 3));
947}

◆ TEST() [170/215]

ui::TEST ( AXTreeTest  ,
ReparentRootIfRootChanged   
)

Definition at line 607 of file ax_tree_unittest.cc.

607 {
609 root.id = 1;
610 AXNodeData child1;
611 child1.id = 2;
612 AXNodeData child2;
613 child2.id = 3;
614
615 root.child_ids = {child1.id};
616 child1.child_ids = {child2.id};
617
618 AXTreeUpdate initial_state;
619 initial_state.root_id = root.id;
620 initial_state.nodes = {root, child1, child2};
621
622 AXTree tree(initial_state);
623
624 // Create a new root and reparent |child2| to be a child of the new root.
625 AXNodeData root2;
626 root2.id = 4;
627 root2.child_ids = {child1.id, child2.id};
628 child1.child_ids = {};
629
631 update.root_id = root2.id;
632 update.node_id_to_clear = root.id;
633 update.nodes = {root2, child1, child2};
634
635 TestAXTreeObserver test_observer(&tree);
636 ASSERT_TRUE(tree.Unserialize(update));
637
638 ASSERT_EQ(1U, test_observer.deleted_ids().size());
639 EXPECT_EQ(root.id, test_observer.deleted_ids()[0]);
640
641 ASSERT_EQ(1U, test_observer.subtree_deleted_ids().size());
642 EXPECT_EQ(root.id, test_observer.subtree_deleted_ids()[0]);
643
644 ASSERT_EQ(1U, test_observer.created_ids().size());
645 EXPECT_EQ(root2.id, test_observer.created_ids()[0]);
646
647 EXPECT_EQ(0U, test_observer.node_creation_finished_ids().size());
648
649 ASSERT_EQ(1U, test_observer.subtree_creation_finished_ids().size());
650 EXPECT_EQ(root2.id, test_observer.subtree_creation_finished_ids()[0]);
651
652 ASSERT_EQ(2U, test_observer.node_reparented_finished_ids().size());
653 EXPECT_EQ(child1.id, test_observer.node_reparented_finished_ids()[0]);
654 EXPECT_EQ(child2.id, test_observer.node_reparented_finished_ids()[1]);
655
656 EXPECT_EQ(0U, test_observer.subtree_reparented_finished_ids().size());
657
658 EXPECT_EQ(0U, test_observer.change_finished_ids().size());
659
660 EXPECT_TRUE(test_observer.root_changed());
661 EXPECT_FALSE(test_observer.tree_data_changed());
662}

◆ TEST() [171/215]

ui::TEST ( AXTreeTest  ,
ReverseRelationsDoNotKeepGrowing   
)

Definition at line 1730 of file ax_tree_unittest.cc.

1730 {
1731 // The number of total entries in int_reverse_relations and
1732 // intlist_reverse_relations should not keep growing as the tree
1733 // changes.
1734
1735 AXTreeUpdate initial_state;
1736 initial_state.root_id = 1;
1737 initial_state.nodes.resize(2);
1738 initial_state.nodes[0].id = 1;
1739 initial_state.nodes[0].AddIntAttribute(
1741 initial_state.nodes[0].AddIntListAttribute(
1743 initial_state.nodes[0].child_ids.push_back(2);
1744 initial_state.nodes[1].id = 2;
1745 AXTree tree(initial_state);
1746
1747 for (int i = 0; i < 1000; ++i) {
1749 update.root_id = 1;
1750 update.nodes.resize(2);
1751 update.nodes[0].id = 1;
1752 update.nodes[1].id = i + 3;
1753 update.nodes[0].AddIntAttribute(
1755 update.nodes[0].AddIntListAttribute(
1757 update.nodes[1].AddIntAttribute(ax::mojom::IntAttribute::kMemberOfId, 1);
1758 update.nodes[0].child_ids.push_back(update.nodes[1].id);
1759 EXPECT_TRUE(tree.Unserialize(update));
1760 }
1761
1762 size_t map_key_count = 0;
1763 size_t set_entry_count = 0;
1764 for (auto& iter : tree.int_reverse_relations()) {
1765 map_key_count += iter.second.size() + 1;
1766 for (auto it2 = iter.second.begin(); it2 != iter.second.end(); ++it2) {
1767 set_entry_count += it2->second.size();
1768 }
1769 }
1770
1771 // Note: 10 is arbitrary, the idea here is just that we mutated the tree
1772 // 1000 times, so if we have fewer than 10 entries in the maps / sets then
1773 // the map isn't growing / leaking. Same below.
1774 EXPECT_LT(map_key_count, 10U);
1775 EXPECT_LT(set_entry_count, 10U);
1776
1777 map_key_count = 0;
1778 set_entry_count = 0;
1779 for (auto& iter : tree.intlist_reverse_relations()) {
1780 map_key_count += iter.second.size() + 1;
1781 for (auto it2 = iter.second.begin(); it2 != iter.second.end(); ++it2) {
1782 set_entry_count += it2->second.size();
1783 }
1784 }
1785 EXPECT_LT(map_key_count, 10U);
1786 EXPECT_LT(set_entry_count, 10U);
1787}

◆ TEST() [172/215]

ui::TEST ( AXTreeTest  ,
RoleAndStateChangeCallbacks   
)

Definition at line 1095 of file ax_tree_unittest.cc.

1095 {
1096 AXTreeUpdate initial_state;
1097 initial_state.root_id = 1;
1098 initial_state.nodes.resize(1);
1099 initial_state.nodes[0].id = 1;
1100 initial_state.nodes[0].role = ax::mojom::Role::kButton;
1101 initial_state.nodes[0].SetCheckedState(ax::mojom::CheckedState::kTrue);
1102 initial_state.nodes[0].AddState(ax::mojom::State::kFocusable);
1103 AXTree tree(initial_state);
1104
1105 TestAXTreeObserver test_observer(&tree);
1106
1107 // Change the role and state.
1109 update.root_id = 1;
1110 update.nodes.resize(1);
1111 update.nodes[0].id = 1;
1112 update.nodes[0].role = ax::mojom::Role::kCheckBox;
1113 update.nodes[0].SetCheckedState(ax::mojom::CheckedState::kFalse);
1114 update.nodes[0].AddState(ax::mojom::State::kFocusable);
1115 update.nodes[0].AddState(ax::mojom::State::kVisited);
1116 EXPECT_TRUE(tree.Unserialize(update));
1117
1118 const std::vector<std::string>& change_log =
1119 test_observer.attribute_change_log();
1120 ASSERT_EQ(3U, change_log.size());
1121 EXPECT_EQ("Role changed from button to checkBox", change_log[0]);
1122 EXPECT_EQ("visited changed to true", change_log[1]);
1123 EXPECT_EQ("checkedState changed from 2 to 1", change_log[2]);
1124}

◆ TEST() [173/215]

ui::TEST ( AXTreeTest  ,
SerializeAXTreeUpdate   
)

Definition at line 297 of file ax_tree_unittest.cc.

297 {
298 AXNodeData list;
299 list.id = 3;
301 list.child_ids.push_back(4);
302 list.child_ids.push_back(5);
303 list.child_ids.push_back(6);
304
305 AXNodeData list_item_2;
306 list_item_2.id = 5;
307 list_item_2.role = ax::mojom::Role::kListItem;
308
309 AXNodeData list_item_3;
310 list_item_3.id = 6;
311 list_item_3.role = ax::mojom::Role::kListItem;
312
313 AXNodeData button;
314 button.id = 7;
316
318 update.root_id = 3;
319 update.nodes.push_back(list);
320 update.nodes.push_back(list_item_2);
321 update.nodes.push_back(list_item_3);
322 update.nodes.push_back(button);
323
324 EXPECT_EQ(
325 "AXTreeUpdate: root id 3\n"
326 "id=3 list (0, 0)-(0, 0) child_ids=4,5,6\n"
327 " id=5 listItem (0, 0)-(0, 0)\n"
328 " id=6 listItem (0, 0)-(0, 0)\n"
329 "id=7 button (0, 0)-(0, 0)\n",
330 update.ToString());
331}

◆ TEST() [174/215]

ui::TEST ( AXTreeTest  ,
SetSizeAssignedOnContainer   
)

Definition at line 3081 of file ax_tree_unittest.cc.

3081 {
3082 AXTreeUpdate tree_update;
3083 tree_update.root_id = 1;
3084 tree_update.nodes.resize(4);
3085 tree_update.nodes[0].id = 1;
3086 tree_update.nodes[0].role = ax::mojom::Role::kList;
3087 tree_update.nodes[0].child_ids = {2, 3, 4};
3088 tree_update.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kSetSize, 7);
3089 tree_update.nodes[1].id = 2;
3090 tree_update.nodes[1].role = ax::mojom::Role::kListItem;
3091 tree_update.nodes[2].id = 3;
3092 tree_update.nodes[2].role = ax::mojom::Role::kListItem;
3093 tree_update.nodes[3].id = 4;
3094 tree_update.nodes[3].role = ax::mojom::Role::kListItem;
3095 AXTree tree(tree_update);
3096
3097 // Items should inherit SetSize from ordered set if not specified.
3098 AXNode* item1 = tree.GetFromId(2);
3099 EXPECT_OPTIONAL_EQ(7, item1->GetSetSize());
3100 EXPECT_OPTIONAL_EQ(1, item1->GetPosInSet());
3101 AXNode* item2 = tree.GetFromId(3);
3102 EXPECT_OPTIONAL_EQ(7, item2->GetSetSize());
3103 EXPECT_OPTIONAL_EQ(2, item2->GetPosInSet());
3104 AXNode* item3 = tree.GetFromId(4);
3105 EXPECT_OPTIONAL_EQ(7, item3->GetSetSize());
3106 EXPECT_OPTIONAL_EQ(3, item3->GetPosInSet());
3107}

◆ TEST() [175/215]

ui::TEST ( AXTreeTest  ,
SetSizeDecreasing   
)

Definition at line 3267 of file ax_tree_unittest.cc.

3267 {
3268 AXTreeUpdate tree_update;
3269 tree_update.root_id = 1;
3270 tree_update.nodes.resize(4);
3271 tree_update.nodes[0].id = 1;
3272 tree_update.nodes[0].role = ax::mojom::Role::kList;
3273 tree_update.nodes[0].child_ids = {2, 3, 4};
3274 tree_update.nodes[1].id = 2;
3275 tree_update.nodes[1].role = ax::mojom::Role::kListItem; // 1 of 5
3276 tree_update.nodes[2].id = 3;
3277 tree_update.nodes[2].role = ax::mojom::Role::kListItem; // 2 of 5
3278 tree_update.nodes[2].AddIntAttribute(ax::mojom::IntAttribute::kSetSize, 5);
3279 tree_update.nodes[3].id = 4;
3280 tree_update.nodes[3].role = ax::mojom::Role::kListItem; // 3 of 5
3281 tree_update.nodes[3].AddIntAttribute(ax::mojom::IntAttribute::kSetSize, 4);
3282 AXTree tree(tree_update);
3283
3284 AXNode* item1 = tree.GetFromId(2);
3285 EXPECT_OPTIONAL_EQ(1, item1->GetPosInSet());
3286 EXPECT_OPTIONAL_EQ(5, item1->GetSetSize());
3287 AXNode* item2 = tree.GetFromId(3);
3288 EXPECT_OPTIONAL_EQ(2, item2->GetPosInSet());
3289 EXPECT_OPTIONAL_EQ(5, item2->GetSetSize());
3290 AXNode* item3 = tree.GetFromId(4);
3291 EXPECT_OPTIONAL_EQ(3, item3->GetPosInSet());
3292 EXPECT_OPTIONAL_EQ(5, item3->GetSetSize());
3293}

◆ TEST() [176/215]

ui::TEST ( AXTreeTest  ,
SetSizePosInSetAddItem   
)

Definition at line 3446 of file ax_tree_unittest.cc.

3446 {
3447 AXTreeUpdate initial_state;
3448 initial_state.root_id = 1;
3449 initial_state.nodes.resize(4);
3450 initial_state.nodes[0].id = 1;
3451 initial_state.nodes[0].role = ax::mojom::Role::kList;
3452 initial_state.nodes[0].child_ids = {2, 3, 4};
3453 initial_state.nodes[1].id = 2;
3454 initial_state.nodes[1].role = ax::mojom::Role::kListItem; // 1 of 3
3455 initial_state.nodes[2].id = 3;
3456 initial_state.nodes[2].role = ax::mojom::Role::kListItem; // 2 of 3
3457 initial_state.nodes[3].id = 4;
3458 initial_state.nodes[3].role = ax::mojom::Role::kListItem; // 3 of 3
3459 AXTree tree(initial_state);
3460
3461 AXNode* item1 = tree.GetFromId(2);
3462 EXPECT_OPTIONAL_EQ(1, item1->GetPosInSet());
3463 EXPECT_OPTIONAL_EQ(3, item1->GetSetSize());
3464 AXNode* item2 = tree.GetFromId(3);
3465 EXPECT_OPTIONAL_EQ(2, item2->GetPosInSet());
3466 EXPECT_OPTIONAL_EQ(3, item2->GetSetSize());
3467 AXNode* item3 = tree.GetFromId(4);
3468 EXPECT_OPTIONAL_EQ(3, item3->GetPosInSet());
3469 EXPECT_OPTIONAL_EQ(3, item3->GetSetSize());
3470
3471 // Insert an item at the beginning of the list.
3472 AXTreeUpdate update = initial_state;
3473 update.nodes.resize(2);
3474 update.nodes[0].id = 1;
3475 update.nodes[0].child_ids = {5, 2, 3, 4};
3476 update.nodes[1].id = 5;
3477 update.nodes[1].role = ax::mojom::Role::kListItem;
3478 ASSERT_TRUE(tree.Unserialize(update));
3479
3480 AXNode* new_item1 = tree.GetFromId(5);
3481 EXPECT_OPTIONAL_EQ(1, new_item1->GetPosInSet());
3482 EXPECT_OPTIONAL_EQ(4, new_item1->GetSetSize());
3483 AXNode* new_item2 = tree.GetFromId(2);
3484 EXPECT_OPTIONAL_EQ(2, new_item2->GetPosInSet());
3485 EXPECT_OPTIONAL_EQ(4, new_item2->GetSetSize());
3486 AXNode* new_item3 = tree.GetFromId(3);
3487 EXPECT_OPTIONAL_EQ(3, new_item3->GetPosInSet());
3488 EXPECT_OPTIONAL_EQ(4, new_item3->GetSetSize());
3489 AXNode* new_item4 = tree.GetFromId(4);
3490 EXPECT_OPTIONAL_EQ(4, new_item4->GetPosInSet());
3491 EXPECT_OPTIONAL_EQ(4, new_item4->GetSetSize());
3492}

◆ TEST() [177/215]

ui::TEST ( AXTreeTest  ,
SetSizePosInSetAssigned   
)

Definition at line 3020 of file ax_tree_unittest.cc.

3020 {
3021 AXTreeUpdate tree_update;
3022 tree_update.root_id = 1;
3023 tree_update.nodes.resize(4);
3024 tree_update.nodes[0].id = 1;
3025 tree_update.nodes[0].role = ax::mojom::Role::kList;
3026 tree_update.nodes[0].child_ids = {2, 3, 4};
3027 tree_update.nodes[1].id = 2;
3028 tree_update.nodes[1].role = ax::mojom::Role::kListItem;
3029 tree_update.nodes[1].AddIntAttribute(ax::mojom::IntAttribute::kPosInSet, 2);
3030 tree_update.nodes[1].AddIntAttribute(ax::mojom::IntAttribute::kSetSize, 12);
3031 tree_update.nodes[2].id = 3;
3032 tree_update.nodes[2].role = ax::mojom::Role::kListItem;
3033 tree_update.nodes[2].AddIntAttribute(ax::mojom::IntAttribute::kPosInSet, 5);
3034 tree_update.nodes[2].AddIntAttribute(ax::mojom::IntAttribute::kSetSize, 12);
3035 tree_update.nodes[3].id = 4;
3036 tree_update.nodes[3].role = ax::mojom::Role::kListItem;
3037 tree_update.nodes[3].AddIntAttribute(ax::mojom::IntAttribute::kPosInSet, 9);
3038 tree_update.nodes[3].AddIntAttribute(ax::mojom::IntAttribute::kSetSize, 12);
3039 AXTree tree(tree_update);
3040
3041 AXNode* item1 = tree.GetFromId(2);
3042 EXPECT_OPTIONAL_EQ(2, item1->GetPosInSet());
3043 EXPECT_OPTIONAL_EQ(12, item1->GetSetSize());
3044 AXNode* item2 = tree.GetFromId(3);
3045 EXPECT_OPTIONAL_EQ(5, item2->GetPosInSet());
3046 EXPECT_OPTIONAL_EQ(12, item2->GetSetSize());
3047 AXNode* item3 = tree.GetFromId(4);
3048 EXPECT_OPTIONAL_EQ(9, item3->GetPosInSet());
3049 EXPECT_OPTIONAL_EQ(12, item3->GetSetSize());
3050}

◆ TEST() [178/215]

ui::TEST ( AXTreeTest  ,
SetSizePosInSetControls   
)

Definition at line 4285 of file ax_tree_unittest.cc.

4285 {
4286 std::vector<int32_t> three;
4287 three.push_back(3);
4288 std::vector<int32_t> hundred;
4289 hundred.push_back(100);
4290 std::vector<int32_t> eight;
4291 eight.push_back(8);
4292 AXTreeUpdate tree_update;
4293 tree_update.root_id = 1;
4294 tree_update.nodes.resize(8);
4295 tree_update.nodes[0].id = 1;
4296 tree_update.nodes[0].role = ax::mojom::Role::kGenericContainer;
4297 tree_update.nodes[0].child_ids = {2, 3, 7, 8};
4298 tree_update.nodes[1].id = 2;
4299 tree_update.nodes[1].role = ax::mojom::Role::kPopUpButton; // SetSize = 3
4300 tree_update.nodes[1].AddIntListAttribute(
4302 tree_update.nodes[1].SetHasPopup(ax::mojom::HasPopup::kMenu);
4303 tree_update.nodes[2].id = 3;
4304 tree_update.nodes[2].role = ax::mojom::Role::kMenu; // SetSize = 3
4305 tree_update.nodes[2].child_ids = {4, 5, 6};
4306 tree_update.nodes[3].id = 4;
4307 tree_update.nodes[3].role = ax::mojom::Role::kMenuItem; // 1 of 3
4308 tree_update.nodes[4].id = 5;
4309 tree_update.nodes[4].role = ax::mojom::Role::kMenuItem; // 2 of 3
4310 tree_update.nodes[5].id = 6;
4311 tree_update.nodes[5].role = ax::mojom::Role::kMenuItem; // 3 of 3
4312 tree_update.nodes[6].id = 7;
4313 tree_update.nodes[6].role =
4314 ax::mojom::Role::kPopUpButton; // Test an invalid controls id.
4315 tree_update.nodes[6].AddIntListAttribute(
4317 // GetSetSize should handle self-references e.g. if a popup button controls
4318 // itself.
4319 tree_update.nodes[7].id = 8;
4320 tree_update.nodes[7].role = ax::mojom::Role::kPopUpButton;
4321 tree_update.nodes[7].AddIntListAttribute(
4323 AXTree tree(tree_update);
4324
4325 AXNode* button = tree.GetFromId(2);
4326 EXPECT_OPTIONAL_EQ(3, button->GetSetSize());
4327 EXPECT_FALSE(button->GetPosInSet());
4328 AXNode* menu = tree.GetFromId(3);
4329 EXPECT_OPTIONAL_EQ(3, menu->GetSetSize());
4330 AXNode* item = tree.GetFromId(4);
4331 EXPECT_OPTIONAL_EQ(1, item->GetPosInSet());
4332 EXPECT_OPTIONAL_EQ(3, item->GetSetSize());
4333 item = tree.GetFromId(5);
4334 EXPECT_OPTIONAL_EQ(2, item->GetPosInSet());
4335 EXPECT_OPTIONAL_EQ(3, item->GetSetSize());
4336 item = tree.GetFromId(6);
4337 EXPECT_OPTIONAL_EQ(3, item->GetPosInSet());
4338 EXPECT_OPTIONAL_EQ(3, item->GetSetSize());
4339 button = tree.GetFromId(7);
4340 EXPECT_OPTIONAL_EQ(0, button->GetSetSize());
4341 button = tree.GetFromId(8);
4342 EXPECT_OPTIONAL_EQ(0, button->GetSetSize());
4343}

◆ TEST() [179/215]

ui::TEST ( AXTreeTest  ,
SetSizePosInSetDeleteItem   
)

Definition at line 3403 of file ax_tree_unittest.cc.

3403 {
3404 AXTreeUpdate initial_state;
3405 initial_state.root_id = 1;
3406 initial_state.nodes.resize(4);
3407 initial_state.nodes[0].id = 1;
3408 initial_state.nodes[0].role = ax::mojom::Role::kList;
3409 initial_state.nodes[0].child_ids = {2, 3, 4};
3410 initial_state.nodes[1].id = 2;
3411 initial_state.nodes[1].role = ax::mojom::Role::kListItem; // 1 of 3
3412 initial_state.nodes[2].id = 3;
3413 initial_state.nodes[2].role = ax::mojom::Role::kListItem; // 2 of 3
3414 initial_state.nodes[3].id = 4;
3415 initial_state.nodes[3].role = ax::mojom::Role::kListItem; // 3 of 3
3416 AXTree tree(initial_state);
3417
3418 AXNode* item1 = tree.GetFromId(2);
3419 EXPECT_OPTIONAL_EQ(1, item1->GetPosInSet());
3420 EXPECT_OPTIONAL_EQ(3, item1->GetSetSize());
3421 AXNode* item2 = tree.GetFromId(3);
3422 EXPECT_OPTIONAL_EQ(2, item2->GetPosInSet());
3423 EXPECT_OPTIONAL_EQ(3, item2->GetSetSize());
3424 AXNode* item3 = tree.GetFromId(4);
3425 EXPECT_OPTIONAL_EQ(3, item3->GetPosInSet());
3426 EXPECT_OPTIONAL_EQ(3, item3->GetSetSize());
3427
3428 // TreeUpdates only need to describe what changed in tree.
3429 AXTreeUpdate update = initial_state;
3430 update.nodes.resize(1);
3431 update.nodes[0].child_ids = {2, 4}; // Delete item 2 of 3 from list.
3432 ASSERT_TRUE(tree.Unserialize(update));
3433
3434 AXNode* new_item1 = tree.GetFromId(2);
3435 EXPECT_OPTIONAL_EQ(1, new_item1->GetPosInSet());
3436 EXPECT_OPTIONAL_EQ(2, new_item1->GetSetSize());
3437 AXNode* new_item2 = tree.GetFromId(4);
3438 EXPECT_OPTIONAL_EQ(2, new_item2->GetPosInSet());
3439 EXPECT_OPTIONAL_EQ(2, new_item2->GetSetSize());
3440}

◆ TEST() [180/215]

ui::TEST ( AXTreeTest  ,
SetSizePosInSetDiverseList   
)

Definition at line 3111 of file ax_tree_unittest.cc.

3111 {
3112 AXTreeUpdate tree_update;
3113 tree_update.root_id = 1;
3114 tree_update.nodes.resize(6);
3115 tree_update.nodes[0].id = 1;
3116 tree_update.nodes[0].role = ax::mojom::Role::kMenu;
3117 tree_update.nodes[0].child_ids = {2, 3, 4, 5, 6};
3118 tree_update.nodes[1].id = 2;
3119 tree_update.nodes[1].role = ax::mojom::Role::kMenuItem; // 1 of 4
3120 tree_update.nodes[2].id = 3;
3121 tree_update.nodes[2].role = ax::mojom::Role::kMenuItemCheckBox; // 2 of 4
3122 tree_update.nodes[3].id = 4;
3123 tree_update.nodes[3].role = ax::mojom::Role::kMenuItemRadio; // 3 of 4
3124 tree_update.nodes[4].id = 5;
3125 tree_update.nodes[4].role = ax::mojom::Role::kMenuItem; // 4 of 4
3126 tree_update.nodes[5].id = 6;
3127 tree_update.nodes[5].role = ax::mojom::Role::kTab; // 0 of 0
3128 AXTree tree(tree_update);
3129
3130 // kMenu is allowed to contain: kMenuItem, kMenuItemCheckbox,
3131 // and kMenuItemRadio. For PosInSet and SetSize purposes, these items
3132 // are treated as the same role.
3133 AXNode* item1 = tree.GetFromId(2);
3134 EXPECT_OPTIONAL_EQ(1, item1->GetPosInSet());
3135 EXPECT_OPTIONAL_EQ(4, item1->GetSetSize());
3136 AXNode* checkbox = tree.GetFromId(3);
3137 EXPECT_OPTIONAL_EQ(2, checkbox->GetPosInSet());
3138 EXPECT_OPTIONAL_EQ(4, checkbox->GetSetSize());
3139 AXNode* radio = tree.GetFromId(4);
3140 EXPECT_OPTIONAL_EQ(3, radio->GetPosInSet());
3141 EXPECT_OPTIONAL_EQ(4, radio->GetSetSize());
3142 AXNode* item3 = tree.GetFromId(5);
3143 EXPECT_OPTIONAL_EQ(4, item3->GetPosInSet());
3144 EXPECT_OPTIONAL_EQ(4, item3->GetSetSize());
3145 AXNode* tab = tree.GetFromId(6);
3146 EXPECT_FALSE(tab->GetPosInSet());
3147 EXPECT_FALSE(tab->GetSetSize());
3148}

◆ TEST() [181/215]

ui::TEST ( AXTreeTest  ,
SetSizePosInSetFlatTree   
)

Definition at line 3772 of file ax_tree_unittest.cc.

3772 {
3773 AXTreeUpdate tree_update;
3774 tree_update.root_id = 1;
3775 tree_update.nodes.resize(4);
3776 tree_update.nodes[0].id = 1;
3777 tree_update.nodes[0].role = ax::mojom::Role::kTree;
3778 tree_update.nodes[0].child_ids = {2, 3, 4};
3779 tree_update.nodes[1].id = 2;
3780 tree_update.nodes[1].role = ax::mojom::Role::kTreeItem; // 1 of 1
3781 tree_update.nodes[1].AddIntAttribute(
3783 tree_update.nodes[2].id = 3;
3784 tree_update.nodes[2].role = ax::mojom::Role::kTreeItem; // 1 of 1
3785 tree_update.nodes[2].AddIntAttribute(
3787 tree_update.nodes[3].id = 4;
3788 tree_update.nodes[3].role = ax::mojom::Role::kTreeItem; // 1 of 1
3789 tree_update.nodes[3].AddIntAttribute(
3791 AXTree tree(tree_update);
3792
3793 AXNode* item1_level1 = tree.GetFromId(2);
3794 EXPECT_OPTIONAL_EQ(1, item1_level1->GetPosInSet());
3795 EXPECT_OPTIONAL_EQ(1, item1_level1->GetSetSize());
3796 AXNode* item1_level2 = tree.GetFromId(3);
3797 EXPECT_OPTIONAL_EQ(1, item1_level2->GetPosInSet());
3798 EXPECT_OPTIONAL_EQ(1, item1_level2->GetSetSize());
3799 AXNode* item1_level3 = tree.GetFromId(4);
3800 EXPECT_OPTIONAL_EQ(1, item1_level3->GetPosInSet());
3801 EXPECT_OPTIONAL_EQ(1, item1_level3->GetSetSize());
3802}

◆ TEST() [182/215]

ui::TEST ( AXTreeTest  ,
SetSizePosInSetFlatTreeLevelsOnly   
)

Definition at line 3806 of file ax_tree_unittest.cc.

3806 {
3807 AXTreeUpdate tree_update;
3808 tree_update.root_id = 1;
3809 tree_update.nodes.resize(9);
3810 tree_update.nodes[0].id = 1;
3811 tree_update.nodes[0].role = ax::mojom::Role::kTree;
3812 tree_update.nodes[0].child_ids = {2, 3, 4, 5, 6, 7, 8, 9};
3813 tree_update.nodes[1].id = 2;
3814 tree_update.nodes[1].role = ax::mojom::Role::kTreeItem; // 1 of 3
3815 tree_update.nodes[1].AddIntAttribute(
3817 tree_update.nodes[2].id = 3;
3818 tree_update.nodes[2].role = ax::mojom::Role::kTreeItem; // 1 of 2
3819 tree_update.nodes[2].AddIntAttribute(
3821 tree_update.nodes[3].id = 4;
3822 tree_update.nodes[3].role = ax::mojom::Role::kTreeItem; // 2 of 2
3823 tree_update.nodes[3].AddIntAttribute(
3825 tree_update.nodes[4].id = 5;
3826 tree_update.nodes[4].role = ax::mojom::Role::kTreeItem; // 2 of 3
3827 tree_update.nodes[4].AddIntAttribute(
3829 tree_update.nodes[5].id = 6;
3830 tree_update.nodes[5].role = ax::mojom::Role::kTreeItem; // 1 of 3
3831 tree_update.nodes[5].AddIntAttribute(
3833 tree_update.nodes[6].id = 7;
3834 tree_update.nodes[6].role = ax::mojom::Role::kTreeItem; // 2 of 3
3835 tree_update.nodes[6].AddIntAttribute(
3837 tree_update.nodes[7].id = 8;
3838 tree_update.nodes[7].role = ax::mojom::Role::kTreeItem; // 3 of 3
3839 tree_update.nodes[7].AddIntAttribute(
3841 tree_update.nodes[8].id = 9;
3842 tree_update.nodes[8].role = ax::mojom::Role::kTreeItem; // 3 of 3
3843 tree_update.nodes[8].AddIntAttribute(
3845 AXTree tree(tree_update);
3846
3847 // The order in which we query the nodes should not matter.
3848 AXNode* item3_level1 = tree.GetFromId(9);
3849 EXPECT_OPTIONAL_EQ(3, item3_level1->GetPosInSet());
3850 EXPECT_OPTIONAL_EQ(3, item3_level1->GetSetSize());
3851 AXNode* item3_level2a = tree.GetFromId(8);
3852 EXPECT_OPTIONAL_EQ(3, item3_level2a->GetPosInSet());
3853 EXPECT_OPTIONAL_EQ(3, item3_level2a->GetSetSize());
3854 AXNode* item2_level2a = tree.GetFromId(7);
3855 EXPECT_OPTIONAL_EQ(2, item2_level2a->GetPosInSet());
3856 EXPECT_OPTIONAL_EQ(3, item2_level2a->GetSetSize());
3857 AXNode* item1_level2a = tree.GetFromId(6);
3858 EXPECT_OPTIONAL_EQ(1, item1_level2a->GetPosInSet());
3859 EXPECT_OPTIONAL_EQ(3, item1_level2a->GetSetSize());
3860 AXNode* item2_level1 = tree.GetFromId(5);
3861 EXPECT_OPTIONAL_EQ(2, item2_level1->GetPosInSet());
3862 EXPECT_OPTIONAL_EQ(3, item2_level1->GetSetSize());
3863 AXNode* item2_level2 = tree.GetFromId(4);
3864 EXPECT_OPTIONAL_EQ(2, item2_level2->GetPosInSet());
3865 EXPECT_OPTIONAL_EQ(2, item2_level2->GetSetSize());
3866 AXNode* item1_level2 = tree.GetFromId(3);
3867 EXPECT_OPTIONAL_EQ(1, item1_level2->GetPosInSet());
3868 EXPECT_OPTIONAL_EQ(2, item1_level2->GetSetSize());
3869 AXNode* item1_level1 = tree.GetFromId(2);
3870 EXPECT_OPTIONAL_EQ(1, item1_level1->GetPosInSet());
3871 EXPECT_OPTIONAL_EQ(3, item1_level1->GetSetSize());
3872 AXNode* ordered_set = tree.GetFromId(1);
3873 EXPECT_OPTIONAL_EQ(3, ordered_set->GetSetSize());
3874}

◆ TEST() [183/215]

ui::TEST ( AXTreeTest  ,
SetSizePosInSetGroup   
)

Definition at line 4087 of file ax_tree_unittest.cc.

4087 {
4088 // The behavior of a group changes depending on the context it appears in
4089 // i.e. if it appears alone vs. if it is contained within another set-like
4090 // element. The below example shows a group standing alone:
4091 //
4092 // <ul role="group"> <!-- SetSize = 3 -->
4093 // <li role="menuitemradio" aria-checked="true">Small</li>
4094 // <li role="menuitemradio" aria-checked="false">Medium</li>
4095 // <li role="menuitemradio" aria-checked="false">Large</li>
4096 // </ul>
4097 //
4098 // However, when it is contained within another set-like element, like a
4099 // listbox, it should simply act like a generic container:
4100 //
4101 // <div role="listbox"> <!-- SetSize = 3 -->
4102 // <div role="option">Red</div> <!-- 1 of 3 -->
4103 // <div role="option">Yellow</div> <!-- 2 of 3 -->
4104 // <div role="group"> <!-- SetSize = 0 -->
4105 // <div role="option">Blue</div> <!-- 3 of 3 -->
4106 // </div>
4107 // </div>
4108 //
4109 // Please note: the GetPosInSet and GetSetSize functions take slightly
4110 // different code paths when initially run on items vs. the container.
4111 // Exercise both code paths in this test.
4112
4113 AXTreeUpdate tree_update;
4114 tree_update.root_id = 1;
4115 tree_update.nodes.resize(6);
4116 tree_update.nodes[0].id = 1;
4117 tree_update.nodes[0].role = ax::mojom::Role::kMenu; // SetSize = 4
4118 tree_update.nodes[0].child_ids = {2, 6};
4119 tree_update.nodes[1].id = 2;
4120 tree_update.nodes[1].role = ax::mojom::Role::kGroup; // SetSize = 0
4121 tree_update.nodes[1].child_ids = {3, 4, 5};
4122 tree_update.nodes[2].id = 3;
4123 tree_update.nodes[2].role = ax::mojom::Role::kMenuItemRadio; // 1 of 4
4124 tree_update.nodes[3].id = 4;
4125 tree_update.nodes[3].role = ax::mojom::Role::kMenuItemRadio; // 2 of 4
4126 tree_update.nodes[4].id = 5;
4127 tree_update.nodes[4].role = ax::mojom::Role::kMenuItemRadio; // 3 of 4
4128 tree_update.nodes[5].id = 6;
4129 tree_update.nodes[5].role = ax::mojom::Role::kMenuItemRadio; // 4 of 4
4130 AXTree tree(tree_update);
4131
4132 // Get data on kMenu first.
4133 AXNode* menu = tree.GetFromId(1);
4134 EXPECT_OPTIONAL_EQ(4, menu->GetSetSize());
4135 AXNode* group = tree.GetFromId(2);
4136 EXPECT_FALSE(group->GetSetSize());
4137 // The below values should have already been computed and cached.
4138 AXNode* item1 = tree.GetFromId(3);
4139 EXPECT_OPTIONAL_EQ(1, item1->GetPosInSet());
4140 EXPECT_OPTIONAL_EQ(4, item1->GetSetSize());
4141 AXNode* item4 = tree.GetFromId(6);
4142 EXPECT_OPTIONAL_EQ(4, item4->GetPosInSet());
4143 EXPECT_OPTIONAL_EQ(4, item4->GetSetSize());
4144
4145 AXTreeUpdate next_tree_update;
4146 next_tree_update.root_id = 1;
4147 next_tree_update.nodes.resize(6);
4148 next_tree_update.nodes[0].id = 1;
4149 next_tree_update.nodes[0].role = ax::mojom::Role::kListBox; // SetSize = 4
4150 next_tree_update.nodes[0].child_ids = {2, 6};
4151 next_tree_update.nodes[1].id = 2;
4152 next_tree_update.nodes[1].role = ax::mojom::Role::kGroup; // SetSize = 0
4153 next_tree_update.nodes[1].child_ids = {3, 4, 5};
4154 next_tree_update.nodes[2].id = 3;
4155 next_tree_update.nodes[2].role = ax::mojom::Role::kListBoxOption; // 1 of 4
4156 next_tree_update.nodes[3].id = 4;
4157 next_tree_update.nodes[3].role = ax::mojom::Role::kListBoxOption; // 2 of 4
4158 next_tree_update.nodes[4].id = 5;
4159 next_tree_update.nodes[4].role = ax::mojom::Role::kListBoxOption; // 3 of 4
4160 next_tree_update.nodes[5].id = 6;
4161 next_tree_update.nodes[5].role = ax::mojom::Role::kListBoxOption; // 4 of 4
4162 AXTree next_tree(next_tree_update);
4163
4164 // Get data on kListBoxOption first.
4165 AXNode* option1 = next_tree.GetFromId(3);
4166 EXPECT_OPTIONAL_EQ(1, option1->GetPosInSet());
4167 EXPECT_OPTIONAL_EQ(4, option1->GetSetSize());
4168 AXNode* option2 = next_tree.GetFromId(4);
4169 EXPECT_OPTIONAL_EQ(2, option2->GetPosInSet());
4170 EXPECT_OPTIONAL_EQ(4, option2->GetSetSize());
4171 AXNode* option3 = next_tree.GetFromId(5);
4172 EXPECT_OPTIONAL_EQ(3, option3->GetPosInSet());
4173 EXPECT_OPTIONAL_EQ(4, option3->GetSetSize());
4174 AXNode* option4 = next_tree.GetFromId(6);
4175 EXPECT_OPTIONAL_EQ(4, option4->GetPosInSet());
4176 EXPECT_OPTIONAL_EQ(4, option4->GetSetSize());
4177 AXNode* next_group = next_tree.GetFromId(2);
4178 EXPECT_FALSE(next_group->GetSetSize());
4179 // The below value should have already been computed and cached.
4180 AXNode* listbox = next_tree.GetFromId(1);
4181 EXPECT_OPTIONAL_EQ(4, listbox->GetSetSize());
4182
4183 // Standalone groups are allowed.
4184 AXTreeUpdate third_tree_update;
4185 third_tree_update.root_id = 1;
4186 third_tree_update.nodes.resize(3);
4187 third_tree_update.nodes[0].id = 1;
4188 third_tree_update.nodes[0].role = ax::mojom::Role::kGroup;
4189 third_tree_update.nodes[0].child_ids = {2, 3};
4190 third_tree_update.nodes[1].id = 2;
4191 third_tree_update.nodes[1].role = ax::mojom::Role::kListItem;
4192 third_tree_update.nodes[2].id = 3;
4193 third_tree_update.nodes[2].role = ax::mojom::Role::kListItem;
4194 AXTree third_tree(third_tree_update);
4195
4196 // Ensure that groups can't also stand alone.
4197 AXNode* last_group = third_tree.GetFromId(1);
4198 EXPECT_OPTIONAL_EQ(2, last_group->GetSetSize());
4199 AXNode* list_item1 = third_tree.GetFromId(2);
4200 EXPECT_OPTIONAL_EQ(1, list_item1->GetPosInSet());
4201 EXPECT_OPTIONAL_EQ(2, list_item1->GetSetSize());
4202 AXNode* list_item2 = third_tree.GetFromId(3);
4203 EXPECT_OPTIONAL_EQ(2, list_item2->GetPosInSet());
4204 EXPECT_OPTIONAL_EQ(2, list_item2->GetSetSize());
4205
4206 // Test nested groups.
4207 AXTreeUpdate last_tree_update;
4208 last_tree_update.root_id = 1;
4209 last_tree_update.nodes.resize(6);
4210 last_tree_update.nodes[0].id = 1;
4211 last_tree_update.nodes[0].role = ax::mojom::Role::kMenuBar;
4212 last_tree_update.nodes[0].child_ids = {2};
4213 last_tree_update.nodes[1].id = 2;
4214 last_tree_update.nodes[1].role = ax::mojom::Role::kGroup;
4215 last_tree_update.nodes[1].child_ids = {3, 4};
4216 last_tree_update.nodes[2].id = 3;
4217 last_tree_update.nodes[2].role = ax::mojom::Role::kMenuItemCheckBox;
4218 last_tree_update.nodes[3].id = 4;
4219 last_tree_update.nodes[3].role = ax::mojom::Role::kGroup;
4220 last_tree_update.nodes[3].child_ids = {5, 6};
4221 last_tree_update.nodes[4].id = 5;
4222 last_tree_update.nodes[4].role = ax::mojom::Role::kMenuItemCheckBox;
4223 last_tree_update.nodes[5].id = 6;
4224 last_tree_update.nodes[5].role = ax::mojom::Role::kMenuItemCheckBox;
4225 AXTree last_tree(last_tree_update);
4226
4227 AXNode* checkbox1 = last_tree.GetFromId(3);
4228 EXPECT_OPTIONAL_EQ(1, checkbox1->GetPosInSet());
4229 EXPECT_OPTIONAL_EQ(3, checkbox1->GetSetSize());
4230 AXNode* checkbox2 = last_tree.GetFromId(5);
4231 EXPECT_OPTIONAL_EQ(2, checkbox2->GetPosInSet());
4232 EXPECT_OPTIONAL_EQ(3, checkbox2->GetSetSize());
4233 AXNode* checkbox3 = last_tree.GetFromId(6);
4234 EXPECT_OPTIONAL_EQ(3, checkbox3->GetPosInSet());
4235 EXPECT_OPTIONAL_EQ(3, checkbox3->GetSetSize());
4236 AXNode* menu_bar = last_tree.GetFromId(1);
4237 EXPECT_OPTIONAL_EQ(3, menu_bar->GetSetSize());
4238 AXNode* outer_group = last_tree.GetFromId(2);
4239 EXPECT_FALSE(outer_group->GetSetSize());
4240 AXNode* inner_group = last_tree.GetFromId(4);
4241 EXPECT_FALSE(inner_group->GetSetSize());
4242}

◆ TEST() [184/215]

ui::TEST ( AXTreeTest  ,
SetSizePosInSetHidden   
)

Definition at line 4244 of file ax_tree_unittest.cc.

4244 {
4245 AXTreeUpdate tree_update;
4246 tree_update.root_id = 1;
4247 tree_update.nodes.resize(6);
4248 tree_update.nodes[0].id = 1;
4249 tree_update.nodes[0].role = ax::mojom::Role::kListBox; // SetSize = 4
4250 tree_update.nodes[0].child_ids = {2, 3, 4, 5, 6};
4251 tree_update.nodes[1].id = 2;
4252 tree_update.nodes[1].role = ax::mojom::Role::kListBoxOption; // 1 of 4
4253 tree_update.nodes[2].id = 3;
4254 tree_update.nodes[2].role = ax::mojom::Role::kListBoxOption; // 2 of 4
4255 tree_update.nodes[3].id = 4;
4256 tree_update.nodes[3].role = ax::mojom::Role::kListBoxOption; // Hidden
4257 tree_update.nodes[3].AddState(ax::mojom::State::kInvisible);
4258 tree_update.nodes[4].id = 5;
4259 tree_update.nodes[4].role = ax::mojom::Role::kListBoxOption; // 3 of 4
4260 tree_update.nodes[5].id = 6;
4261 tree_update.nodes[5].role = ax::mojom::Role::kListBoxOption; // 4 of 4
4262 AXTree tree(tree_update);
4263
4264 AXNode* list_box = tree.GetFromId(1);
4265 EXPECT_OPTIONAL_EQ(4, list_box->GetSetSize());
4266 AXNode* option1 = tree.GetFromId(2);
4267 EXPECT_OPTIONAL_EQ(1, option1->GetPosInSet());
4268 EXPECT_OPTIONAL_EQ(4, option1->GetSetSize());
4269 AXNode* option2 = tree.GetFromId(3);
4270 EXPECT_OPTIONAL_EQ(2, option2->GetPosInSet());
4271 EXPECT_OPTIONAL_EQ(4, option2->GetSetSize());
4272 AXNode* option_hidden = tree.GetFromId(4);
4273 EXPECT_FALSE(option_hidden->GetPosInSet());
4274 EXPECT_FALSE(option_hidden->GetSetSize());
4275 AXNode* option3 = tree.GetFromId(5);
4276 EXPECT_OPTIONAL_EQ(3, option3->GetPosInSet());
4277 EXPECT_OPTIONAL_EQ(4, option3->GetSetSize());
4278 AXNode* option4 = tree.GetFromId(6);
4279 EXPECT_OPTIONAL_EQ(4, option4->GetPosInSet());
4280 EXPECT_OPTIONAL_EQ(4, option4->GetSetSize());
4281}

◆ TEST() [185/215]

ui::TEST ( AXTreeTest  ,
SetSizePosInSetIgnoredItem   
)

Definition at line 3919 of file ax_tree_unittest.cc.

3919 {
3920 AXTreeUpdate initial_state;
3921 initial_state.root_id = 1;
3922 initial_state.nodes.resize(3);
3923 initial_state.nodes[0].id = 1;
3924 initial_state.nodes[0].role = ax::mojom::Role::kTree;
3925 initial_state.nodes[0].child_ids = {2, 3};
3926 initial_state.nodes[1].id = 2;
3927 initial_state.nodes[1].role = ax::mojom::Role::kTreeItem;
3928 initial_state.nodes[2].id = 3;
3929 initial_state.nodes[2].role = ax::mojom::Role::kTreeItem;
3930 AXTree tree(initial_state);
3931
3932 AXNode* tree_node = tree.GetFromId(1);
3933 AXNode* item1 = tree.GetFromId(2);
3934 AXNode* item2 = tree.GetFromId(3);
3935
3936 // This should work normally.
3937 ASSERT_FALSE(tree_node->GetPosInSet());
3938 EXPECT_OPTIONAL_EQ(2, tree_node->GetSetSize());
3939
3940 EXPECT_OPTIONAL_EQ(1, item1->GetPosInSet());
3941 EXPECT_OPTIONAL_EQ(2, item1->GetSetSize());
3942
3943 EXPECT_OPTIONAL_EQ(2, item2->GetPosInSet());
3944 EXPECT_OPTIONAL_EQ(2, item2->GetSetSize());
3945
3946 // Remove item from tree.
3947 AXTreeUpdate tree_update;
3948 tree_update.nodes.resize(1);
3949 tree_update.nodes[0] = initial_state.nodes[1];
3950 tree_update.nodes[0].AddState(ax::mojom::State::kIgnored);
3951
3952 ASSERT_TRUE(tree.Unserialize(tree_update));
3953
3954 ASSERT_FALSE(tree_node->GetPosInSet());
3955 EXPECT_OPTIONAL_EQ(1, tree_node->GetSetSize());
3956
3957 // Ignored nodes are not part of ordered sets.
3958 EXPECT_FALSE(item1->GetPosInSet());
3959 EXPECT_FALSE(item1->GetSetSize());
3960
3961 EXPECT_OPTIONAL_EQ(1, item2->GetPosInSet());
3962 EXPECT_OPTIONAL_EQ(1, item2->GetSetSize());
3963}

◆ TEST() [186/215]

ui::TEST ( AXTreeTest  ,
SetSizePosInSetInvalid   
)

Definition at line 3579 of file ax_tree_unittest.cc.

3579 {
3580 AXTreeUpdate tree_update;
3581 tree_update.root_id = 1;
3582 tree_update.nodes.resize(3);
3583 tree_update.nodes[0].id = 1;
3584 tree_update.nodes[0].role = ax::mojom::Role::kListItem; // 0 of 0
3585 tree_update.nodes[0].child_ids = {2, 3};
3586 tree_update.nodes[1].id = 2;
3587 tree_update.nodes[1].role = ax::mojom::Role::kListItem;
3588 tree_update.nodes[1].AddIntAttribute(ax::mojom::IntAttribute::kPosInSet,
3589 4); // 0 of 0
3590 tree_update.nodes[2].id = 3;
3591 tree_update.nodes[2].role = ax::mojom::Role::kListItem;
3592 AXTree tree(tree_update);
3593
3594 AXNode* item1 = tree.GetFromId(1);
3595 EXPECT_FALSE(item1->GetPosInSet());
3596 EXPECT_FALSE(item1->GetSetSize());
3597 AXNode* item2 = tree.GetFromId(2);
3598 EXPECT_FALSE(item2->GetPosInSet());
3599 EXPECT_FALSE(item2->GetSetSize());
3600 AXNode* item3 = tree.GetFromId(3);
3601 EXPECT_FALSE(item3->GetPosInSet());
3602 EXPECT_FALSE(item3->GetSetSize());
3603}

◆ TEST() [187/215]

ui::TEST ( AXTreeTest  ,
SetSizePosInSetLeafPopUpButton   
)

Definition at line 4347 of file ax_tree_unittest.cc.

4347 {
4348 AXTreeUpdate tree_update;
4349 tree_update.root_id = 1;
4350 tree_update.nodes.resize(2);
4351 tree_update.nodes[0].id = 1;
4352 tree_update.nodes[0].role = ax::mojom::Role::kGenericContainer;
4353 tree_update.nodes[0].child_ids = {2};
4354 tree_update.nodes[1].id = 2;
4355 tree_update.nodes[1].role = ax::mojom::Role::kPopUpButton;
4356 tree_update.nodes[1].AddIntAttribute(ax::mojom::IntAttribute::kPosInSet, 3);
4357 tree_update.nodes[1].AddIntAttribute(ax::mojom::IntAttribute::kSetSize, 77);
4358 AXTree tree(tree_update);
4359
4360 AXNode* pop_up_button = tree.GetFromId(2);
4361 EXPECT_OPTIONAL_EQ(3, pop_up_button->GetPosInSet());
4362 EXPECT_OPTIONAL_EQ(77, pop_up_button->GetSetSize());
4363}

◆ TEST() [188/215]

ui::TEST ( AXTreeTest  ,
SetSizePosInSetMenuItemValidChildOfMenuListPopup   
)

Definition at line 4027 of file ax_tree_unittest.cc.

4027 {
4028 AXTreeUpdate initial_state;
4029 initial_state.root_id = 1;
4030 initial_state.nodes.resize(3);
4031 initial_state.nodes[0].id = 1;
4032 initial_state.nodes[0].child_ids = {2, 3};
4033 initial_state.nodes[0].role = ax::mojom::Role::kMenuListPopup;
4034 initial_state.nodes[1].id = 2;
4035 initial_state.nodes[1].role = ax::mojom::Role::kMenuItem;
4036 initial_state.nodes[2].id = 3;
4037 initial_state.nodes[2].role = ax::mojom::Role::kMenuListOption;
4038 AXTree tree(initial_state);
4039
4040 AXNode* menu = tree.GetFromId(1);
4041 EXPECT_OPTIONAL_EQ(2, menu->GetSetSize());
4042 AXNode* item1 = tree.GetFromId(2);
4043 EXPECT_OPTIONAL_EQ(1, item1->GetPosInSet());
4044 EXPECT_OPTIONAL_EQ(2, item1->GetSetSize());
4045 AXNode* item2 = tree.GetFromId(3);
4046 EXPECT_OPTIONAL_EQ(2, item2->GetPosInSet());
4047 EXPECT_OPTIONAL_EQ(2, item2->GetSetSize());
4048}

◆ TEST() [189/215]

ui::TEST ( AXTreeTest  ,
SetSizePosInSetMissingDifficult   
)

Definition at line 3225 of file ax_tree_unittest.cc.

3225 {
3226 AXTreeUpdate tree_update;
3227 tree_update.root_id = 1;
3228 tree_update.nodes.resize(6);
3229 tree_update.nodes[0].id = 1;
3230 tree_update.nodes[0].role = ax::mojom::Role::kList;
3231 tree_update.nodes[0].child_ids = {2, 3, 4, 5, 6};
3232 tree_update.nodes[1].id = 2;
3233 tree_update.nodes[1].role = ax::mojom::Role::kListItem; // 1 of 11
3234 tree_update.nodes[2].id = 3;
3235 tree_update.nodes[2].role = ax::mojom::Role::kListItem;
3236 tree_update.nodes[2].AddIntAttribute(ax::mojom::IntAttribute::kPosInSet,
3237 5); // 5 of 11
3238 tree_update.nodes[3].id = 4;
3239 tree_update.nodes[3].role = ax::mojom::Role::kListItem; // 6 of 11
3240 tree_update.nodes[4].id = 5;
3241 tree_update.nodes[4].role = ax::mojom::Role::kListItem;
3242 tree_update.nodes[4].AddIntAttribute(ax::mojom::IntAttribute::kPosInSet,
3243 10); // 10 of 11
3244 tree_update.nodes[5].id = 6;
3245 tree_update.nodes[5].role = ax::mojom::Role::kListItem; // 11 of 11
3246 AXTree tree(tree_update);
3247
3248 AXNode* item1 = tree.GetFromId(2);
3249 EXPECT_OPTIONAL_EQ(1, item1->GetPosInSet());
3250 EXPECT_OPTIONAL_EQ(11, item1->GetSetSize());
3251 AXNode* item2 = tree.GetFromId(3);
3252 EXPECT_OPTIONAL_EQ(5, item2->GetPosInSet());
3253 EXPECT_OPTIONAL_EQ(11, item2->GetSetSize());
3254 AXNode* item3 = tree.GetFromId(4);
3255 EXPECT_OPTIONAL_EQ(6, item3->GetPosInSet());
3256 EXPECT_OPTIONAL_EQ(11, item3->GetSetSize());
3257 AXNode* item4 = tree.GetFromId(5);
3258 EXPECT_OPTIONAL_EQ(10, item4->GetPosInSet());
3259 EXPECT_OPTIONAL_EQ(11, item4->GetSetSize());
3260 AXNode* item5 = tree.GetFromId(6);
3261 EXPECT_OPTIONAL_EQ(11, item5->GetPosInSet());
3262 EXPECT_OPTIONAL_EQ(11, item5->GetSetSize());
3263}

◆ TEST() [190/215]

ui::TEST ( AXTreeTest  ,
SetSizePosInSetNestedContainer   
)

Definition at line 3358 of file ax_tree_unittest.cc.

3358 {
3359 AXTreeUpdate tree_update;
3360 tree_update.root_id = 1;
3361 tree_update.nodes.resize(7);
3362 tree_update.nodes[0].id = 1;
3363 tree_update.nodes[0].role = ax::mojom::Role::kList;
3364 tree_update.nodes[0].child_ids = {2, 3, 7};
3365 tree_update.nodes[1].id = 2;
3366 tree_update.nodes[1].role = ax::mojom::Role::kListItem; // 1 of 4
3367 tree_update.nodes[2].id = 3;
3368 tree_update.nodes[2].role = ax::mojom::Role::kGenericContainer;
3369 tree_update.nodes[2].child_ids = {4, 5};
3370 tree_update.nodes[3].id = 4;
3371 tree_update.nodes[3].role = ax::mojom::Role::kListItem; // 2 of 4
3372 tree_update.nodes[4].id = 5;
3373 tree_update.nodes[4].role = ax::mojom::Role::kIgnored;
3374 tree_update.nodes[4].child_ids = {6};
3375 tree_update.nodes[5].id = 6;
3376 tree_update.nodes[5].role = ax::mojom::Role::kListItem; // 3 of 4
3377 tree_update.nodes[6].id = 7;
3378 tree_update.nodes[6].role = ax::mojom::Role::kListItem; // 4 of 4
3379 AXTree tree(tree_update);
3380
3381 AXNode* item1 = tree.GetFromId(2);
3382 EXPECT_OPTIONAL_EQ(1, item1->GetPosInSet());
3383 EXPECT_OPTIONAL_EQ(4, item1->GetSetSize());
3384 AXNode* g_container = tree.GetFromId(3);
3385 EXPECT_FALSE(g_container->GetPosInSet());
3386 EXPECT_FALSE(g_container->GetSetSize());
3387 AXNode* item2 = tree.GetFromId(4);
3388 EXPECT_OPTIONAL_EQ(2, item2->GetPosInSet());
3389 EXPECT_OPTIONAL_EQ(4, item2->GetSetSize());
3390 AXNode* ignored = tree.GetFromId(5);
3391 EXPECT_FALSE(ignored->GetPosInSet());
3392 EXPECT_FALSE(ignored->GetSetSize());
3393 AXNode* item3 = tree.GetFromId(6);
3394 EXPECT_OPTIONAL_EQ(3, item3->GetPosInSet());
3395 EXPECT_OPTIONAL_EQ(4, item3->GetSetSize());
3396 AXNode* item4 = tree.GetFromId(7);
3397 EXPECT_OPTIONAL_EQ(4, item4->GetPosInSet());
3398 EXPECT_OPTIONAL_EQ(4, item4->GetSetSize());
3399}

◆ TEST() [191/215]

ui::TEST ( AXTreeTest  ,
SetSizePosInSetNestedList   
)

Definition at line 3151 of file ax_tree_unittest.cc.

3151 {
3152 AXTreeUpdate tree_update;
3153 tree_update.root_id = 1;
3154 tree_update.nodes.resize(7);
3155 tree_update.nodes[0].id = 1;
3156 tree_update.nodes[0].role = ax::mojom::Role::kList;
3157 tree_update.nodes[0].child_ids = {2, 3, 4, 7};
3158 tree_update.nodes[1].id = 2;
3159 tree_update.nodes[1].role = ax::mojom::Role::kListItem;
3160 tree_update.nodes[2].id = 3;
3161 tree_update.nodes[2].role = ax::mojom::Role::kListItem;
3162 tree_update.nodes[3].id = 4;
3163 tree_update.nodes[3].role = ax::mojom::Role::kList;
3164 tree_update.nodes[3].child_ids = {5, 6};
3165 tree_update.nodes[4].id = 5;
3166 tree_update.nodes[4].role = ax::mojom::Role::kListItem;
3167 tree_update.nodes[5].id = 6;
3168 tree_update.nodes[5].role = ax::mojom::Role::kListItem;
3169 tree_update.nodes[6].id = 7;
3170 tree_update.nodes[6].role = ax::mojom::Role::kListItem;
3171 AXTree tree(tree_update);
3172
3173 AXNode* outer_item1 = tree.GetFromId(2);
3174 EXPECT_OPTIONAL_EQ(1, outer_item1->GetPosInSet());
3175 EXPECT_OPTIONAL_EQ(3, outer_item1->GetSetSize());
3176 AXNode* outer_item2 = tree.GetFromId(3);
3177 EXPECT_OPTIONAL_EQ(2, outer_item2->GetPosInSet());
3178 EXPECT_OPTIONAL_EQ(3, outer_item2->GetSetSize());
3179
3180 AXNode* inner_item1 = tree.GetFromId(5);
3181 EXPECT_OPTIONAL_EQ(1, inner_item1->GetPosInSet());
3182 EXPECT_OPTIONAL_EQ(2, inner_item1->GetSetSize());
3183 AXNode* inner_item2 = tree.GetFromId(6);
3184 EXPECT_OPTIONAL_EQ(2, inner_item2->GetPosInSet());
3185 EXPECT_OPTIONAL_EQ(2, inner_item2->GetSetSize());
3186
3187 AXNode* outer_item3 = tree.GetFromId(7);
3188 EXPECT_OPTIONAL_EQ(3, outer_item3->GetPosInSet());
3189 EXPECT_OPTIONAL_EQ(3, outer_item3->GetSetSize());
3190}

◆ TEST() [192/215]

ui::TEST ( AXTreeTest  ,
SetSizePosInSetPopUpButton   
)

Definition at line 3967 of file ax_tree_unittest.cc.

3967 {
3968 AXTreeUpdate initial_state;
3969 initial_state.root_id = 1;
3970 initial_state.nodes.resize(6);
3971 initial_state.nodes[0].id = 1;
3972 initial_state.nodes[0].child_ids = {2, 3};
3973 initial_state.nodes[1].id = 2;
3974 initial_state.nodes[1].role = ax::mojom::Role::kPopUpButton;
3975 initial_state.nodes[2].id = 3;
3976 initial_state.nodes[2].role = ax::mojom::Role::kPopUpButton;
3977 initial_state.nodes[2].child_ids = {4};
3978 initial_state.nodes[3].id = 4;
3979 initial_state.nodes[3].role = ax::mojom::Role::kMenuListPopup;
3980 initial_state.nodes[3].child_ids = {5, 6};
3981 initial_state.nodes[4].id = 5;
3982 initial_state.nodes[4].role = ax::mojom::Role::kMenuListOption;
3983 initial_state.nodes[5].id = 6;
3984 initial_state.nodes[5].role = ax::mojom::Role::kMenuListOption;
3985 AXTree tree(initial_state);
3986
3987 // The first popupbutton should have SetSize of 0.
3988 AXNode* popup_button_1 = tree.GetFromId(2);
3989 EXPECT_OPTIONAL_EQ(0, popup_button_1->GetSetSize());
3990 // The second popupbutton should have SetSize of 2, since the menulistpopup
3991 // that it wraps has a SetSize of 2.
3992 AXNode* popup_button_2 = tree.GetFromId(3);
3993 EXPECT_OPTIONAL_EQ(2, popup_button_2->GetSetSize());
3994}

◆ TEST() [193/215]

ui::TEST ( AXTreeTest  ,
SetSizePosInSetRadioButtons   
)

Definition at line 3608 of file ax_tree_unittest.cc.

3608 {
3609 AXTreeUpdate tree_update;
3610 tree_update.root_id = 1;
3611 tree_update.nodes.resize(13);
3612 tree_update.nodes[0].id = 1;
3613 tree_update.nodes[0].child_ids = {2, 3, 4, 10, 13};
3614 // This test passes because the root node is a kRadioGroup.
3615 tree_update.nodes[0].role = ax::mojom::Role::kRadioGroup; // Setsize = 5;
3616
3617 // Radio buttons are not required to be contained within an ordered set.
3618 tree_update.nodes[1].id = 2;
3619 tree_update.nodes[1].role = ax::mojom::Role::kRadioButton; // 1 of 5
3620 tree_update.nodes[1].AddStringAttribute(ax::mojom::StringAttribute::kName,
3621 "sports");
3622 tree_update.nodes[1].AddIntAttribute(ax::mojom::IntAttribute::kPosInSet, 1);
3623 tree_update.nodes[2].id = 3;
3624 tree_update.nodes[2].role = ax::mojom::Role::kRadioButton; // 2 of 5
3625 tree_update.nodes[2].AddStringAttribute(ax::mojom::StringAttribute::kName,
3626 "books");
3627 tree_update.nodes[2].AddIntAttribute(ax::mojom::IntAttribute::kPosInSet, 2);
3628 tree_update.nodes[2].AddIntAttribute(ax::mojom::IntAttribute::kSetSize, 5);
3629
3630 // Radio group with nested generic container.
3631 tree_update.nodes[3].id = 4;
3632 tree_update.nodes[3].role = ax::mojom::Role::kRadioGroup; // setsize = 4
3633 tree_update.nodes[3].child_ids = {5, 6, 7};
3634 tree_update.nodes[4].id = 5;
3635 tree_update.nodes[4].role = ax::mojom::Role::kRadioButton;
3636 tree_update.nodes[4].AddStringAttribute(ax::mojom::StringAttribute::kName,
3637 "recipes"); // 1 of 4
3638 tree_update.nodes[5].id = 6;
3639 tree_update.nodes[5].role = ax::mojom::Role::kRadioButton;
3640 tree_update.nodes[5].AddStringAttribute(ax::mojom::StringAttribute::kName,
3641 "recipes"); // 2 of 4
3642 tree_update.nodes[6].id = 7;
3643 tree_update.nodes[6].role = ax::mojom::Role::kGenericContainer;
3644 tree_update.nodes[6].child_ids = {8, 9};
3645 tree_update.nodes[7].id = 8;
3646 tree_update.nodes[7].role = ax::mojom::Role::kRadioButton;
3647 tree_update.nodes[7].AddStringAttribute(ax::mojom::StringAttribute::kName,
3648 "recipes"); // 3 of 4
3649 tree_update.nodes[8].id = 9;
3650 tree_update.nodes[8].role = ax::mojom::Role::kRadioButton;
3651 tree_update.nodes[8].AddStringAttribute(ax::mojom::StringAttribute::kName,
3652 "recipes"); // 4 of 4
3653
3654 // Radio buttons are allowed to be contained within forms.
3655 tree_update.nodes[9].id = 10;
3656 tree_update.nodes[9].role = ax::mojom::Role::kForm;
3657 tree_update.nodes[9].child_ids = {11, 12};
3658 tree_update.nodes[10].id = 11;
3659 tree_update.nodes[10].role = ax::mojom::Role::kRadioButton;
3660 tree_update.nodes[10].AddStringAttribute(ax::mojom::StringAttribute::kName,
3661 "cities"); // 1 of 2
3662 tree_update.nodes[11].id = 12;
3663 tree_update.nodes[11].role = ax::mojom::Role::kRadioButton;
3664 tree_update.nodes[11].AddStringAttribute(ax::mojom::StringAttribute::kName,
3665 "cities"); // 2 of 2
3666 tree_update.nodes[12].id = 13;
3667 tree_update.nodes[12].role = ax::mojom::Role::kRadioButton; // 4 of 5
3668 tree_update.nodes[12].AddStringAttribute(ax::mojom::StringAttribute::kName,
3669 "sports");
3670 tree_update.nodes[12].AddIntAttribute(ax::mojom::IntAttribute::kPosInSet, 4);
3671
3672 AXTree tree(tree_update);
3673
3674 AXNode* sports_button1 = tree.GetFromId(2);
3675 EXPECT_OPTIONAL_EQ(1, sports_button1->GetPosInSet());
3676 EXPECT_OPTIONAL_EQ(5, sports_button1->GetSetSize());
3677 AXNode* books_button = tree.GetFromId(3);
3678 EXPECT_OPTIONAL_EQ(2, books_button->GetPosInSet());
3679 EXPECT_OPTIONAL_EQ(5, books_button->GetSetSize());
3680
3681 AXNode* radiogroup1 = tree.GetFromId(4);
3682 EXPECT_FALSE(radiogroup1->GetPosInSet());
3683 EXPECT_OPTIONAL_EQ(4, radiogroup1->GetSetSize());
3684 AXNode* recipes_button1 = tree.GetFromId(5);
3685 EXPECT_OPTIONAL_EQ(1, recipes_button1->GetPosInSet());
3686 EXPECT_OPTIONAL_EQ(4, recipes_button1->GetSetSize());
3687 AXNode* recipes_button2 = tree.GetFromId(6);
3688 EXPECT_OPTIONAL_EQ(2, recipes_button2->GetPosInSet());
3689 EXPECT_OPTIONAL_EQ(4, recipes_button2->GetSetSize());
3690
3691 AXNode* generic_container = tree.GetFromId(7);
3692 EXPECT_FALSE(generic_container->GetPosInSet());
3693 EXPECT_FALSE(generic_container->GetSetSize());
3694 AXNode* recipes_button3 = tree.GetFromId(8);
3695 EXPECT_OPTIONAL_EQ(3, recipes_button3->GetPosInSet());
3696 EXPECT_OPTIONAL_EQ(4, recipes_button3->GetSetSize());
3697 AXNode* recipes_button4 = tree.GetFromId(9);
3698 EXPECT_OPTIONAL_EQ(4, recipes_button4->GetPosInSet());
3699 EXPECT_OPTIONAL_EQ(4, recipes_button4->GetSetSize());
3700
3701 // Elements with role kForm shouldn't report posinset or setsize
3702 AXNode* form = tree.GetFromId(10);
3703 EXPECT_FALSE(form->GetPosInSet());
3704 EXPECT_FALSE(form->GetSetSize());
3705 AXNode* cities_button1 = tree.GetFromId(11);
3706 EXPECT_OPTIONAL_EQ(1, cities_button1->GetPosInSet());
3707 EXPECT_OPTIONAL_EQ(2, cities_button1->GetSetSize());
3708 AXNode* cities_button2 = tree.GetFromId(12);
3709 EXPECT_OPTIONAL_EQ(2, cities_button2->GetPosInSet());
3710 EXPECT_OPTIONAL_EQ(2, cities_button2->GetSetSize());
3711
3712 AXNode* sports_button2 = tree.GetFromId(13);
3713 EXPECT_OPTIONAL_EQ(4, sports_button2->GetPosInSet());
3714 EXPECT_OPTIONAL_EQ(5, sports_button2->GetSetSize());
3715}

◆ TEST() [194/215]

ui::TEST ( AXTreeTest  ,
SetSizePosInSetRadioButtonsInList   
)

Definition at line 3720 of file ax_tree_unittest.cc.

3720 {
3721 AXTreeUpdate tree_update;
3722 tree_update.root_id = 1;
3723 tree_update.nodes.resize(6);
3724 tree_update.nodes[0].id = 1;
3725 tree_update.nodes[0].role =
3726 ax::mojom::Role::kList; // SetSize = 2, since only base::contains 2
3727 // ListItems
3728 tree_update.nodes[0].child_ids = {2, 3, 4, 5, 6};
3729
3730 tree_update.nodes[1].id = 2;
3731 tree_update.nodes[1].role = ax::mojom::Role::kRadioButton; // 1 of 3
3732 tree_update.nodes[2].id = 3;
3733 tree_update.nodes[2].role = ax::mojom::Role::kListItem; // 1 of 2
3734 tree_update.nodes[3].id = 4;
3735 tree_update.nodes[3].role = ax::mojom::Role::kRadioButton; // 2 of 3
3736 tree_update.nodes[4].id = 5;
3737 tree_update.nodes[4].role = ax::mojom::Role::kListItem; // 2 of 2
3738 tree_update.nodes[5].id = 6;
3739 tree_update.nodes[5].role = ax::mojom::Role::kRadioButton; // 3 of 3
3740 AXTree tree(tree_update);
3741
3742 AXNode* list = tree.GetFromId(1);
3743 EXPECT_FALSE(list->GetPosInSet());
3744 EXPECT_OPTIONAL_EQ(2, list->GetSetSize());
3745
3746 AXNode* radiobutton1 = tree.GetFromId(2);
3747 EXPECT_OPTIONAL_EQ(1, radiobutton1->GetPosInSet());
3748 EXPECT_OPTIONAL_EQ(3, radiobutton1->GetSetSize());
3749 AXNode* item1 = tree.GetFromId(3);
3750 EXPECT_OPTIONAL_EQ(1, item1->GetPosInSet());
3751 EXPECT_OPTIONAL_EQ(2, item1->GetSetSize());
3752 AXNode* radiobutton2 = tree.GetFromId(4);
3753 EXPECT_OPTIONAL_EQ(2, radiobutton2->GetPosInSet());
3754 EXPECT_OPTIONAL_EQ(3, radiobutton2->GetSetSize());
3755 AXNode* item2 = tree.GetFromId(5);
3756 EXPECT_OPTIONAL_EQ(2, item2->GetPosInSet());
3757 EXPECT_OPTIONAL_EQ(2, item2->GetSetSize());
3758 AXNode* radiobutton3 = tree.GetFromId(6);
3759 EXPECT_OPTIONAL_EQ(3, radiobutton3->GetPosInSet());
3760 EXPECT_OPTIONAL_EQ(3, radiobutton3->GetSetSize());
3761
3762 // Ensure that the setsize of list was not modified after calling GetPosInSet
3763 // and GetSetSize on kRadioButtons.
3764 EXPECT_FALSE(list->GetPosInSet());
3765 EXPECT_OPTIONAL_EQ(2, list->GetSetSize());
3766}

◆ TEST() [195/215]

ui::TEST ( AXTreeTest  ,
SetSizePosInSetSubtreeDeleted   
)

Definition at line 3878 of file ax_tree_unittest.cc.

3878 {
3879 AXTreeUpdate initial_state;
3880 initial_state.root_id = 1;
3881 initial_state.nodes.resize(3);
3882 initial_state.nodes[0].id = 1;
3883 initial_state.nodes[0].role = ax::mojom::Role::kTree;
3884 initial_state.nodes[0].child_ids = {2, 3};
3885 initial_state.nodes[1].id = 2;
3886 initial_state.nodes[1].role = ax::mojom::Role::kTreeItem;
3887 initial_state.nodes[2].id = 3;
3888 initial_state.nodes[2].role = ax::mojom::Role::kTreeItem;
3889 AXTree tree(initial_state);
3890
3891 AXNode* tree_node = tree.GetFromId(1);
3892 AXNode* item = tree.GetFromId(3);
3893
3894 // This should work normally.
3895 EXPECT_OPTIONAL_EQ(2, item->GetPosInSet());
3896 EXPECT_OPTIONAL_EQ(2, item->GetSetSize());
3897
3898 // Remove item from tree.
3899 AXTreeUpdate tree_update = initial_state;
3900 tree_update.nodes.resize(1);
3901 tree_update.nodes[0].child_ids = {2};
3902
3903 ASSERT_TRUE(tree.Unserialize(tree_update));
3904
3905 // These values are lazily created, so to test that they fail when
3906 // called in the middle of a tree update, fake the update state.
3907 tree.SetTreeUpdateInProgressState(true);
3908 ASSERT_FALSE(tree_node->GetPosInSet());
3909 ASSERT_FALSE(tree_node->GetSetSize());
3910
3911 // Then reset the state to make sure we have the expected values
3912 // after |Unserialize|.
3913 tree.SetTreeUpdateInProgressState(false);
3914 ASSERT_FALSE(tree_node->GetPosInSet());
3915 EXPECT_OPTIONAL_EQ(1, tree_node->GetSetSize());
3916}

◆ TEST() [196/215]

ui::TEST ( AXTreeTest  ,
SetSizePosInSetUnassigned   
)

Definition at line 3053 of file ax_tree_unittest.cc.

3053 {
3054 AXTreeUpdate tree_update;
3055 tree_update.root_id = 1;
3056 tree_update.nodes.resize(4);
3057 tree_update.nodes[0].id = 1;
3058 tree_update.nodes[0].role = ax::mojom::Role::kList;
3059 tree_update.nodes[0].child_ids = {2, 3, 4};
3060 tree_update.nodes[1].id = 2;
3061 tree_update.nodes[1].role = ax::mojom::Role::kListItem;
3062 tree_update.nodes[2].id = 3;
3063 tree_update.nodes[2].role = ax::mojom::Role::kListItem;
3064 tree_update.nodes[3].id = 4;
3065 tree_update.nodes[3].role = ax::mojom::Role::kListItem;
3066 AXTree tree(tree_update);
3067
3068 AXNode* item1 = tree.GetFromId(2);
3069 EXPECT_OPTIONAL_EQ(1, item1->GetPosInSet());
3070 EXPECT_OPTIONAL_EQ(3, item1->GetSetSize());
3071 AXNode* item2 = tree.GetFromId(3);
3072 EXPECT_OPTIONAL_EQ(2, item2->GetPosInSet());
3073 EXPECT_OPTIONAL_EQ(3, item2->GetSetSize());
3074 AXNode* item3 = tree.GetFromId(4);
3075 EXPECT_OPTIONAL_EQ(3, item3->GetPosInSet());
3076 EXPECT_OPTIONAL_EQ(3, item3->GetSetSize());
3077}

◆ TEST() [197/215]

ui::TEST ( AXTreeTest  ,
SetSizePosInSetUnkown   
)

Definition at line 3998 of file ax_tree_unittest.cc.

3998 {
3999 AXTreeUpdate initial_state;
4000 initial_state.root_id = 1;
4001 initial_state.nodes.resize(5);
4002 initial_state.nodes[0].id = 1;
4003 initial_state.nodes[0].child_ids = {2};
4004 initial_state.nodes[0].role = ax::mojom::Role::kMenu;
4005 initial_state.nodes[1].id = 2;
4006 initial_state.nodes[1].role = ax::mojom::Role::kUnknown;
4007 initial_state.nodes[1].child_ids = {3};
4008 initial_state.nodes[2].id = 3;
4009 initial_state.nodes[2].role = ax::mojom::Role::kUnknown;
4010 initial_state.nodes[2].child_ids = {4, 5};
4011 initial_state.nodes[3].id = 4;
4012 initial_state.nodes[3].role = ax::mojom::Role::kMenuItem;
4013 initial_state.nodes[4].id = 5;
4014 initial_state.nodes[4].role = ax::mojom::Role::kMenuItem;
4015 AXTree tree(initial_state);
4016
4017 AXNode* menu = tree.GetFromId(1);
4018 EXPECT_OPTIONAL_EQ(2, menu->GetSetSize());
4019 AXNode* item1 = tree.GetFromId(4);
4020 EXPECT_OPTIONAL_EQ(1, item1->GetPosInSet());
4021 EXPECT_OPTIONAL_EQ(2, item1->GetSetSize());
4022 AXNode* item2 = tree.GetFromId(5);
4023 EXPECT_OPTIONAL_EQ(2, item2->GetPosInSet());
4024 EXPECT_OPTIONAL_EQ(2, item2->GetSetSize());
4025}

◆ TEST() [198/215]

ui::TEST ( AXTreeTest  ,
SetSizePostInSetListBoxOptionWithGroup   
)

Definition at line 4050 of file ax_tree_unittest.cc.

4050 {
4051 AXTreeUpdate initial_state;
4052 initial_state.root_id = 1;
4053 initial_state.nodes.resize(7);
4054 initial_state.nodes[0].id = 1;
4055 initial_state.nodes[0].child_ids = {2, 3};
4056 initial_state.nodes[0].role = ax::mojom::Role::kListBox;
4057 initial_state.nodes[1].id = 2;
4058 initial_state.nodes[1].child_ids = {4, 5};
4059 initial_state.nodes[1].role = ax::mojom::Role::kGroup;
4060 initial_state.nodes[2].id = 3;
4061 initial_state.nodes[2].child_ids = {6, 7};
4062 initial_state.nodes[2].role = ax::mojom::Role::kGroup;
4063 initial_state.nodes[3].id = 4;
4064 initial_state.nodes[3].role = ax::mojom::Role::kListBoxOption;
4065 initial_state.nodes[4].id = 5;
4066 initial_state.nodes[4].role = ax::mojom::Role::kListBoxOption;
4067 initial_state.nodes[5].id = 6;
4068 initial_state.nodes[5].role = ax::mojom::Role::kListBoxOption;
4069 initial_state.nodes[6].id = 7;
4070 initial_state.nodes[6].role = ax::mojom::Role::kListBoxOption;
4071 AXTree tree(initial_state);
4072
4073 AXNode* listbox_option1 = tree.GetFromId(4);
4074 EXPECT_OPTIONAL_EQ(1, listbox_option1->GetPosInSet());
4075 EXPECT_OPTIONAL_EQ(4, listbox_option1->GetSetSize());
4076 AXNode* listbox_option2 = tree.GetFromId(5);
4077 EXPECT_OPTIONAL_EQ(2, listbox_option2->GetPosInSet());
4078 EXPECT_OPTIONAL_EQ(4, listbox_option2->GetSetSize());
4079 AXNode* listbox_option3 = tree.GetFromId(6);
4080 EXPECT_OPTIONAL_EQ(3, listbox_option3->GetPosInSet());
4081 EXPECT_OPTIONAL_EQ(4, listbox_option3->GetSetSize());
4082 AXNode* listbox_option4 = tree.GetFromId(7);
4083 EXPECT_OPTIONAL_EQ(4, listbox_option4->GetPosInSet());
4084 EXPECT_OPTIONAL_EQ(4, listbox_option4->GetSetSize());
4085}

◆ TEST() [199/215]

ui::TEST ( AXTreeTest  ,
SingleUpdateDeletesNewlyCreatedChildNode   
)

Definition at line 4443 of file ax_tree_unittest.cc.

4443 {
4444 AXTreeUpdate initial_state;
4445 initial_state.root_id = 1;
4446 initial_state.nodes.resize(1);
4447 initial_state.nodes[0].id = 1;
4448 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
4449 AXTree tree(initial_state);
4450
4451 AXTreeUpdate tree_update;
4452 tree_update.nodes.resize(6);
4453 // Add child node:2
4454 tree_update.nodes[0] = initial_state.nodes[0];
4455 tree_update.nodes[0].child_ids = {2};
4456 tree_update.nodes[1].id = 2;
4457 tree_update.nodes[1].role = ax::mojom::Role::kGenericContainer;
4458 // Remove child node:2
4459 tree_update.nodes[2] = initial_state.nodes[0];
4460 // Add child node:2
4461 tree_update.nodes[3] = initial_state.nodes[0];
4462 tree_update.nodes[3].child_ids = {2};
4463 tree_update.nodes[4].id = 2;
4464 tree_update.nodes[4].role = ax::mojom::Role::kGenericContainer;
4465 // Remove child node:2
4466 tree_update.nodes[5] = initial_state.nodes[0];
4467
4468 ASSERT_TRUE(tree.Unserialize(tree_update)) << tree.error();
4469
4470 ASSERT_EQ(
4471 "AXTree\n"
4472 "id=1 rootWebArea (0, 0)-(0, 0)\n",
4473 tree.ToString());
4474
4475 // Unserialize again, but with another add child.
4476 tree_update.nodes.resize(8);
4477 tree_update.nodes[6] = initial_state.nodes[0];
4478 tree_update.nodes[6].child_ids = {2};
4479 tree_update.nodes[7].id = 2;
4480 tree_update.nodes[7].role = ax::mojom::Role::kGenericContainer;
4481 ASSERT_TRUE(tree.Unserialize(tree_update)) << tree.error();
4482
4483 ASSERT_EQ(
4484 "AXTree\n"
4485 "id=1 rootWebArea (0, 0)-(0, 0) child_ids=2\n"
4486 " id=2 genericContainer (0, 0)-(0, 0)\n",
4487 tree.ToString());
4488}

◆ TEST() [200/215]

ui::TEST ( AXTreeTest  ,
SingleUpdateIgnoresNewlyCreatedUnignoredChildNode   
)

Definition at line 4560 of file ax_tree_unittest.cc.

4560 {
4561 AXTreeUpdate initial_state;
4562 initial_state.root_id = 1;
4563 initial_state.nodes.resize(1);
4564 initial_state.nodes[0].id = 1;
4565 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
4566 AXTree tree(initial_state);
4567
4568 AXTreeUpdate tree_update;
4569 tree_update.nodes.resize(3);
4570 // Add child node:2
4571 tree_update.nodes[0] = initial_state.nodes[0];
4572 tree_update.nodes[0].child_ids = {2};
4573 tree_update.nodes[1].id = 2;
4574 tree_update.nodes[1].role = ax::mojom::Role::kGenericContainer;
4575 // Add State::kIgnored to node:2
4576 tree_update.nodes[2] = tree_update.nodes[1];
4577 tree_update.nodes[2].AddState(ax::mojom::State::kIgnored);
4578
4579 ASSERT_TRUE(tree.Unserialize(tree_update)) << tree.error();
4580
4581 ASSERT_EQ(
4582 "AXTree\n"
4583 "id=1 rootWebArea (0, 0)-(0, 0) child_ids=2\n"
4584 " id=2 genericContainer IGNORED (0, 0)-(0, 0)\n",
4585 tree.ToString());
4586}

◆ TEST() [201/215]

ui::TEST ( AXTreeTest  ,
SingleUpdateReparentsNodeMultipleTimes   
)

Definition at line 4493 of file ax_tree_unittest.cc.

4493 {
4494 // ++{kRootWebArea, 1}
4495 // ++++{kList, 2}
4496 // ++++++{kListItem, 4}
4497 // ++++{kList, 3}
4498 AXTreeUpdate initial_state;
4499 initial_state.root_id = 1;
4500 initial_state.nodes.resize(4);
4501 initial_state.nodes[0].id = 1;
4502 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
4503 initial_state.nodes[0].child_ids = {2, 3};
4504 initial_state.nodes[1].id = 2;
4505 initial_state.nodes[1].role = ax::mojom::Role::kList;
4506 initial_state.nodes[1].child_ids = {4};
4507 initial_state.nodes[2].id = 3;
4508 initial_state.nodes[2].role = ax::mojom::Role::kList;
4509 initial_state.nodes[3].id = 4;
4510 initial_state.nodes[3].role = ax::mojom::Role::kListItem;
4511 AXTree tree(initial_state);
4512
4513 AXTreeUpdate tree_update;
4514 tree_update.nodes.resize(6);
4515 // Remove child node:4
4516 tree_update.nodes[0].id = 2;
4517 tree_update.nodes[0].role = ax::mojom::Role::kList;
4518 // Reparent child node:4 onto node:3
4519 tree_update.nodes[1].id = 3;
4520 tree_update.nodes[1].role = ax::mojom::Role::kList;
4521 tree_update.nodes[1].child_ids = {4};
4522 tree_update.nodes[2].id = 4;
4523 tree_update.nodes[2].role = ax::mojom::Role::kListItem;
4524 // Remove child ndoe:4
4525 tree_update.nodes[3].id = 3;
4526 tree_update.nodes[3].role = ax::mojom::Role::kList;
4527 // Reparent child node:4 onto node:2
4528 tree_update.nodes[4].id = 2;
4529 tree_update.nodes[4].role = ax::mojom::Role::kList;
4530 tree_update.nodes[4].child_ids = {4};
4531 tree_update.nodes[5].id = 4;
4532 tree_update.nodes[5].role = ax::mojom::Role::kListItem;
4533
4534 ASSERT_TRUE(tree.Unserialize(tree_update)) << tree.error();
4535 EXPECT_EQ(
4536 "AXTree\nid=1 rootWebArea (0, 0)-(0, 0) child_ids=2,3\n"
4537 " id=2 list (0, 0)-(0, 0) child_ids=4\n"
4538 " id=4 listItem (0, 0)-(0, 0)\n"
4539 " id=3 list (0, 0)-(0, 0)\n",
4540 tree.ToString());
4541
4542 // Unserialize again, but with another reparent.
4543 tree_update.nodes.resize(9);
4544 tree_update.nodes[6] = tree_update.nodes[0];
4545 tree_update.nodes[7] = tree_update.nodes[1];
4546 tree_update.nodes[8] = tree_update.nodes[2];
4547
4548 ASSERT_TRUE(tree.Unserialize(tree_update)) << tree.error();
4549 EXPECT_EQ(
4550 "AXTree\nid=1 rootWebArea (0, 0)-(0, 0) child_ids=2,3\n"
4551 " id=2 list (0, 0)-(0, 0)\n"
4552 " id=3 list (0, 0)-(0, 0) child_ids=4\n"
4553 " id=4 listItem (0, 0)-(0, 0)\n",
4554 tree.ToString());
4555}

◆ TEST() [202/215]

ui::TEST ( AXTreeTest  ,
SingleUpdateTogglesIgnoredStateAfterCreatingNode   
)

Definition at line 4591 of file ax_tree_unittest.cc.

4591 {
4592 AXTreeUpdate initial_state;
4593 initial_state.root_id = 1;
4594 initial_state.nodes.resize(1);
4595 initial_state.nodes[0].id = 1;
4596 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
4597 AXTree tree(initial_state);
4598
4599 ASSERT_EQ(
4600 "AXTree\n"
4601 "id=1 rootWebArea (0, 0)-(0, 0)\n",
4602 tree.ToString());
4603
4604 AXTreeUpdate tree_update;
4605 tree_update.nodes.resize(5);
4606 // Add child node:2, node:3
4607 tree_update.nodes[0] = initial_state.nodes[0];
4608 tree_update.nodes[0].child_ids = {2, 3};
4609 tree_update.nodes[1].id = 2;
4610 tree_update.nodes[1].role = ax::mojom::Role::kGenericContainer;
4611 tree_update.nodes[2].id = 3;
4612 tree_update.nodes[2].role = ax::mojom::Role::kGenericContainer;
4613 tree_update.nodes[2].AddState(ax::mojom::State::kIgnored);
4614 // Add State::kIgnored to node:2
4615 tree_update.nodes[3] = tree_update.nodes[1];
4616 tree_update.nodes[3].AddState(ax::mojom::State::kIgnored);
4617 // Remove State::kIgnored from node:3
4618 tree_update.nodes[4] = tree_update.nodes[2];
4619 tree_update.nodes[4].RemoveState(ax::mojom::State::kIgnored);
4620
4621 ASSERT_TRUE(tree.Unserialize(tree_update)) << tree.error();
4622
4623 ASSERT_EQ(
4624 "AXTree\n"
4625 "id=1 rootWebArea (0, 0)-(0, 0) child_ids=2,3\n"
4626 " id=2 genericContainer IGNORED (0, 0)-(0, 0)\n"
4627 " id=3 genericContainer (0, 0)-(0, 0)\n",
4628 tree.ToString());
4629}

◆ TEST() [203/215]

ui::TEST ( AXTreeTest  ,
SingleUpdateTogglesIgnoredStateBeforeDestroyingNode   
)

Definition at line 4634 of file ax_tree_unittest.cc.

4634 {
4635 AXTreeUpdate initial_state;
4636 initial_state.root_id = 1;
4637 initial_state.nodes.resize(3);
4638 initial_state.nodes[0].id = 1;
4639 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
4640 initial_state.nodes[0].child_ids = {2, 3};
4641 initial_state.nodes[1].id = 2;
4642 initial_state.nodes[1].role = ax::mojom::Role::kGenericContainer;
4643 initial_state.nodes[2].id = 3;
4644 initial_state.nodes[2].role = ax::mojom::Role::kGenericContainer;
4645 initial_state.nodes[2].AddState(ax::mojom::State::kIgnored);
4646 AXTree tree(initial_state);
4647
4648 ASSERT_EQ(
4649 "AXTree\n"
4650 "id=1 rootWebArea (0, 0)-(0, 0) child_ids=2,3\n"
4651 " id=2 genericContainer (0, 0)-(0, 0)\n"
4652 " id=3 genericContainer IGNORED (0, 0)-(0, 0)\n",
4653 tree.ToString());
4654
4655 AXTreeUpdate tree_update;
4656 tree_update.nodes.resize(3);
4657 // Add State::kIgnored to node:2
4658 tree_update.nodes[0] = initial_state.nodes[1];
4659 tree_update.nodes[0].AddState(ax::mojom::State::kIgnored);
4660 // Remove State::kIgnored from node:3
4661 tree_update.nodes[1] = initial_state.nodes[2];
4662 tree_update.nodes[1].RemoveState(ax::mojom::State::kIgnored);
4663 // Remove child node:2, node:3
4664 tree_update.nodes[2] = initial_state.nodes[0];
4665 tree_update.nodes[2].child_ids.clear();
4666
4667 ASSERT_TRUE(tree.Unserialize(tree_update)) << tree.error();
4668
4669 ASSERT_EQ(
4670 "AXTree\n"
4671 "id=1 rootWebArea (0, 0)-(0, 0)\n",
4672 tree.ToString());
4673}

◆ TEST() [204/215]

ui::TEST ( AXTreeTest  ,
SkipIgnoredNodes   
)

Definition at line 1789 of file ax_tree_unittest.cc.

1789 {
1790 AXTreeUpdate tree_update;
1791 tree_update.root_id = 1;
1792 tree_update.nodes.resize(5);
1793 tree_update.nodes[0].id = 1;
1794 tree_update.nodes[0].child_ids = {2, 3};
1795 tree_update.nodes[1].id = 2;
1796 tree_update.nodes[1].AddState(ax::mojom::State::kIgnored);
1797 tree_update.nodes[1].child_ids = {4, 5};
1798 tree_update.nodes[2].id = 3;
1799 tree_update.nodes[3].id = 4;
1800 tree_update.nodes[4].id = 5;
1801
1802 AXTree tree(tree_update);
1803 AXNode* root = tree.root();
1804 ASSERT_EQ(2u, root->children().size());
1805 ASSERT_EQ(2, root->children()[0]->id());
1806 ASSERT_EQ(3, root->children()[1]->id());
1807
1808 EXPECT_EQ(3u, root->GetUnignoredChildCount());
1809 EXPECT_EQ(4, root->GetUnignoredChildAtIndex(0)->id());
1810 EXPECT_EQ(5, root->GetUnignoredChildAtIndex(1)->id());
1811 EXPECT_EQ(3, root->GetUnignoredChildAtIndex(2)->id());
1812 EXPECT_EQ(0u, root->GetUnignoredChildAtIndex(0)->GetUnignoredIndexInParent());
1813 EXPECT_EQ(1u, root->GetUnignoredChildAtIndex(1)->GetUnignoredIndexInParent());
1814 EXPECT_EQ(2u, root->GetUnignoredChildAtIndex(2)->GetUnignoredIndexInParent());
1815
1816 EXPECT_EQ(1, root->GetUnignoredChildAtIndex(0)->GetUnignoredParent()->id());
1817}

◆ TEST() [205/215]

ui::TEST ( AXTreeTest  ,
TestIsInListMarker   
)

Definition at line 4677 of file ax_tree_unittest.cc.

4677 {
4678 // This test uses the template of a list of one element: "1. List item"
4679 AXTreeUpdate tree_update;
4680 tree_update.root_id = 1;
4681 tree_update.nodes.resize(8);
4682 tree_update.nodes[0].id = 1;
4683 tree_update.nodes[0].role = ax::mojom::Role::kList;
4684 tree_update.nodes[0].child_ids = {2, 3};
4685 tree_update.nodes[1].id = 2;
4686 tree_update.nodes[1].role = ax::mojom::Role::kListItem;
4687 tree_update.nodes[2].id = 3;
4688 tree_update.nodes[2].child_ids = {4, 7};
4689 tree_update.nodes[3].id = 4;
4690 tree_update.nodes[3].role = ax::mojom::Role::kListMarker;
4691 tree_update.nodes[3].child_ids = {5};
4692 tree_update.nodes[4].id = 5;
4693 tree_update.nodes[4].role = ax::mojom::Role::kStaticText; // "1. "
4694 tree_update.nodes[4].child_ids = {6};
4695 tree_update.nodes[5].id = 6;
4696 tree_update.nodes[5].role = ax::mojom::Role::kInlineTextBox; // "1. "
4697 tree_update.nodes[6].id = 7;
4698 tree_update.nodes[6].role = ax::mojom::Role::kStaticText; // "List item"
4699 tree_update.nodes[6].child_ids = {8};
4700 tree_update.nodes[7].id = 8;
4701 tree_update.nodes[7].role = ax::mojom::Role::kInlineTextBox; // "List item"
4702 AXTree tree(tree_update);
4703
4704 AXNode* list_node = tree.GetFromId(1);
4705 ASSERT_EQ(false, list_node->IsInListMarker());
4706
4707 AXNode* list_item_node = tree.GetFromId(2);
4708 ASSERT_EQ(false, list_item_node->IsInListMarker());
4709
4710 AXNode* list_marker1 = tree.GetFromId(4);
4711 ASSERT_EQ(true, list_marker1->IsInListMarker());
4712
4713 AXNode* static_node1 = tree.GetFromId(5);
4714 ASSERT_EQ(true, static_node1->IsInListMarker());
4715
4716 AXNode* inline_node1 = tree.GetFromId(6);
4717 ASSERT_EQ(true, inline_node1->IsInListMarker());
4718
4719 AXNode* static_node2 = tree.GetFromId(7);
4720 ASSERT_EQ(false, static_node2->IsInListMarker());
4721
4722 AXNode* inline_node2 = tree.GetFromId(8);
4723 ASSERT_EQ(false, inline_node2->IsInListMarker());
4724}

◆ TEST() [206/215]

ui::TEST ( AXTreeTest  ,
TestRecursionUnignoredChildCount   
)

Definition at line 1936 of file ax_tree_unittest.cc.

1936 {
1937 AXTreeUpdate tree_update;
1938 tree_update.root_id = 1;
1939 tree_update.nodes.resize(5);
1940 tree_update.nodes[0].id = 1;
1941 tree_update.nodes[0].child_ids = {2, 3};
1942 tree_update.nodes[1].id = 2;
1943 tree_update.nodes[1].AddState(ax::mojom::State::kIgnored);
1944 tree_update.nodes[1].child_ids = {4};
1945 tree_update.nodes[2].id = 3;
1946 tree_update.nodes[2].AddState(ax::mojom::State::kIgnored);
1947 tree_update.nodes[3].id = 4;
1948 tree_update.nodes[3].child_ids = {5};
1949 tree_update.nodes[3].AddState(ax::mojom::State::kIgnored);
1950 tree_update.nodes[4].id = 5;
1951 AXTree tree(tree_update);
1952
1953 AXNode* root = tree.root();
1954 EXPECT_EQ(2u, root->children().size());
1955 EXPECT_EQ(1u, root->GetUnignoredChildCount());
1956 EXPECT_EQ(5, root->GetUnignoredChildAtIndex(0)->id());
1957 AXNode* unignored = tree.GetFromId(5);
1958 EXPECT_EQ(0u, unignored->GetUnignoredChildCount());
1959}

◆ TEST() [207/215]

ui::TEST ( AXTreeTest  ,
TreeObserverIsCalled   
)

Definition at line 844 of file ax_tree_unittest.cc.

844 {
845 AXTreeUpdate initial_state;
846 initial_state.root_id = 1;
847 initial_state.nodes.resize(2);
848 initial_state.nodes[0].id = 1;
849 initial_state.nodes[0].child_ids.push_back(2);
850 initial_state.nodes[1].id = 2;
851
852 AXTree tree(initial_state);
854 update.root_id = 3;
855 update.node_id_to_clear = 1;
856 update.nodes.resize(2);
857 update.nodes[0].id = 3;
858 update.nodes[0].child_ids.push_back(4);
859 update.nodes[1].id = 4;
860
861 TestAXTreeObserver test_observer(&tree);
862 ASSERT_TRUE(tree.Unserialize(update));
863
864 ASSERT_EQ(2U, test_observer.deleted_ids().size());
865 EXPECT_EQ(1, test_observer.deleted_ids()[0]);
866 EXPECT_EQ(2, test_observer.deleted_ids()[1]);
867
868 ASSERT_EQ(1U, test_observer.subtree_deleted_ids().size());
869 EXPECT_EQ(1, test_observer.subtree_deleted_ids()[0]);
870
871 ASSERT_EQ(2U, test_observer.created_ids().size());
872 EXPECT_EQ(3, test_observer.created_ids()[0]);
873 EXPECT_EQ(4, test_observer.created_ids()[1]);
874
875 ASSERT_EQ(1U, test_observer.subtree_creation_finished_ids().size());
876 EXPECT_EQ(3, test_observer.subtree_creation_finished_ids()[0]);
877
878 ASSERT_EQ(1U, test_observer.node_creation_finished_ids().size());
879 EXPECT_EQ(4, test_observer.node_creation_finished_ids()[0]);
880
881 ASSERT_TRUE(test_observer.root_changed());
882}

◆ TEST() [208/215]

ui::TEST ( AXTreeTest  ,
TreeObserverIsCalledForTreeDataChanges   
)

Definition at line 884 of file ax_tree_unittest.cc.

884 {
885 AXTreeUpdate initial_state;
886 initial_state.root_id = 1;
887 initial_state.nodes.resize(1);
888 initial_state.nodes[0].id = 1;
889 initial_state.has_tree_data = true;
890 initial_state.tree_data.title = "Initial";
891 AXTree tree(initial_state);
892
893 TestAXTreeObserver test_observer(&tree);
894
895 // An empty update shouldn't change tree data.
896 AXTreeUpdate empty_update;
897 EXPECT_TRUE(tree.Unserialize(empty_update));
898 EXPECT_FALSE(test_observer.tree_data_changed());
899 EXPECT_EQ("Initial", tree.data().title);
900
901 // An update with tree data shouldn't change tree data if
902 // |has_tree_data| isn't set.
903 AXTreeUpdate ignored_tree_data_update;
904 ignored_tree_data_update.tree_data.title = "Ignore Me";
905 EXPECT_TRUE(tree.Unserialize(ignored_tree_data_update));
906 EXPECT_FALSE(test_observer.tree_data_changed());
907 EXPECT_EQ("Initial", tree.data().title);
908
909 // An update with |has_tree_data| set should update the tree data.
910 AXTreeUpdate tree_data_update;
911 tree_data_update.has_tree_data = true;
912 tree_data_update.tree_data.title = "New Title";
913 EXPECT_TRUE(tree.Unserialize(tree_data_update));
914 EXPECT_TRUE(test_observer.tree_data_changed());
915 EXPECT_EQ("New Title", tree.data().title);
916}

◆ TEST() [209/215]

ui::TEST ( AXTreeTest  ,
TreeObserverIsNotCalledForReparenting   
)

Definition at line 1009 of file ax_tree_unittest.cc.

1009 {
1010 AXTreeUpdate initial_state;
1011 initial_state.root_id = 1;
1012 initial_state.nodes.resize(2);
1013 initial_state.nodes[0].id = 1;
1014 initial_state.nodes[0].child_ids.push_back(2);
1015 initial_state.nodes[1].id = 2;
1016
1017 AXTree tree(initial_state);
1019 update.node_id_to_clear = 1;
1020 update.root_id = 2;
1021 update.nodes.resize(2);
1022 update.nodes[0].id = 2;
1023 update.nodes[0].child_ids.push_back(4);
1024 update.nodes[1].id = 4;
1025
1026 TestAXTreeObserver test_observer(&tree);
1027
1028 EXPECT_TRUE(tree.Unserialize(update));
1029
1030 ASSERT_EQ(1U, test_observer.deleted_ids().size());
1031 EXPECT_EQ(1, test_observer.deleted_ids()[0]);
1032
1033 ASSERT_EQ(1U, test_observer.subtree_deleted_ids().size());
1034 EXPECT_EQ(1, test_observer.subtree_deleted_ids()[0]);
1035
1036 ASSERT_EQ(1U, test_observer.created_ids().size());
1037 EXPECT_EQ(4, test_observer.created_ids()[0]);
1038
1039 ASSERT_EQ(1U, test_observer.subtree_creation_finished_ids().size());
1040 EXPECT_EQ(4, test_observer.subtree_creation_finished_ids()[0]);
1041
1042 ASSERT_EQ(1U, test_observer.subtree_reparented_finished_ids().size());
1043 EXPECT_EQ(2, test_observer.subtree_reparented_finished_ids()[0]);
1044
1045 EXPECT_EQ(0U, test_observer.node_creation_finished_ids().size());
1046 EXPECT_EQ(0U, test_observer.node_reparented_finished_ids().size());
1047
1048 ASSERT_TRUE(test_observer.root_changed());
1049}

◆ TEST() [210/215]

ui::TEST ( AXTreeTest  ,
UnignoredAccessors   
)

Definition at line 2275 of file ax_tree_unittest.cc.

2275 {
2276 AXTreeUpdate tree_update;
2277 // (i) => node is ignored
2278 // 1
2279 // |__________
2280 // | | |
2281 // 2(i) 3 4
2282 // |_______________________
2283 // | | | |
2284 // 5 6 7(i) 8(i)
2285 // | | |________
2286 // | | | |
2287 // 9 10(i) 11(i) 12
2288 // | |____
2289 // | | |
2290 // 13(i) 14 15
2291 // | |
2292 // 16 17(i)
2293 tree_update.root_id = 1;
2294 tree_update.nodes.resize(17);
2295 tree_update.nodes[0].id = 1;
2296 tree_update.nodes[0].child_ids = {2, 3, 4};
2297
2298 tree_update.nodes[1].id = 2;
2299 tree_update.nodes[1].child_ids = {5, 6, 7, 8};
2300 tree_update.nodes[1].AddState(ax::mojom::State::kIgnored);
2301
2302 tree_update.nodes[2].id = 3;
2303 tree_update.nodes[3].id = 4;
2304
2305 tree_update.nodes[4].id = 5;
2306 tree_update.nodes[4].child_ids = {9};
2307
2308 tree_update.nodes[5].id = 6;
2309 tree_update.nodes[5].child_ids = {10};
2310
2311 tree_update.nodes[6].id = 7;
2312 tree_update.nodes[6].child_ids = {11, 12};
2313 tree_update.nodes[6].AddState(ax::mojom::State::kIgnored);
2314
2315 tree_update.nodes[7].id = 8;
2316 tree_update.nodes[7].AddState(ax::mojom::State::kIgnored);
2317
2318 tree_update.nodes[8].id = 9;
2319
2320 tree_update.nodes[9].id = 10;
2321 tree_update.nodes[9].child_ids = {13};
2322 tree_update.nodes[9].AddState(ax::mojom::State::kIgnored);
2323
2324 tree_update.nodes[10].id = 11;
2325 tree_update.nodes[10].child_ids = {14, 15};
2326 tree_update.nodes[10].AddState(ax::mojom::State::kIgnored);
2327
2328 tree_update.nodes[11].id = 12;
2329
2330 tree_update.nodes[12].id = 13;
2331 tree_update.nodes[12].child_ids = {16};
2332 tree_update.nodes[12].AddState(ax::mojom::State::kIgnored);
2333
2334 tree_update.nodes[13].id = 14;
2335 tree_update.nodes[13].child_ids = {17};
2336
2337 tree_update.nodes[14].id = 15;
2338
2339 tree_update.nodes[15].id = 16;
2340
2341 tree_update.nodes[16].id = 17;
2342 tree_update.nodes[16].AddState(ax::mojom::State::kIgnored);
2343
2344 AXTree tree(tree_update);
2345
2346 EXPECT_EQ(4, tree.GetFromId(1)->GetLastUnignoredChild()->id());
2347 EXPECT_EQ(12, tree.GetFromId(2)->GetLastUnignoredChild()->id());
2348 EXPECT_EQ(nullptr, tree.GetFromId(3)->GetLastUnignoredChild());
2349 EXPECT_EQ(nullptr, tree.GetFromId(4)->GetLastUnignoredChild());
2350 EXPECT_EQ(9, tree.GetFromId(5)->GetLastUnignoredChild()->id());
2351 EXPECT_EQ(16, tree.GetFromId(6)->GetLastUnignoredChild()->id());
2352 EXPECT_EQ(12, tree.GetFromId(7)->GetLastUnignoredChild()->id());
2353 EXPECT_EQ(nullptr, tree.GetFromId(8)->GetLastUnignoredChild());
2354 EXPECT_EQ(nullptr, tree.GetFromId(9)->GetLastUnignoredChild());
2355 EXPECT_EQ(16, tree.GetFromId(10)->GetLastUnignoredChild()->id());
2356 EXPECT_EQ(15, tree.GetFromId(11)->GetLastUnignoredChild()->id());
2357 EXPECT_EQ(nullptr, tree.GetFromId(12)->GetLastUnignoredChild());
2358 EXPECT_EQ(16, tree.GetFromId(13)->GetLastUnignoredChild()->id());
2359 EXPECT_EQ(nullptr, tree.GetFromId(14)->GetLastUnignoredChild());
2360 EXPECT_EQ(nullptr, tree.GetFromId(15)->GetLastUnignoredChild());
2361 EXPECT_EQ(nullptr, tree.GetFromId(16)->GetLastUnignoredChild());
2362 EXPECT_EQ(nullptr, tree.GetFromId(17)->GetLastUnignoredChild());
2363}

◆ TEST() [211/215]

ui::TEST ( AXTreeTest  ,
UnignoredChildIterator   
)

Definition at line 2152 of file ax_tree_unittest.cc.

2152 {
2153 AXTreeUpdate tree_update;
2154 // (i) => node is ignored
2155 // 1
2156 // |__________
2157 // | | |
2158 // 2(i) 3 4
2159 // |_______________________
2160 // | | | |
2161 // 5 6 7(i) 8(i)
2162 // | | |________
2163 // | | | |
2164 // 9 10(i) 11(i) 12
2165 // | |____
2166 // | | |
2167 // 13(i) 14 15
2168 tree_update.root_id = 1;
2169 tree_update.nodes.resize(15);
2170 tree_update.nodes[0].id = 1;
2171 tree_update.nodes[0].child_ids = {2, 3, 4};
2172
2173 tree_update.nodes[1].id = 2;
2174 tree_update.nodes[1].child_ids = {5, 6, 7, 8};
2175 tree_update.nodes[1].AddState(ax::mojom::State::kIgnored);
2176
2177 tree_update.nodes[2].id = 3;
2178 tree_update.nodes[3].id = 4;
2179
2180 tree_update.nodes[4].id = 5;
2181 tree_update.nodes[4].child_ids = {9};
2182
2183 tree_update.nodes[5].id = 6;
2184 tree_update.nodes[5].child_ids = {10};
2185
2186 tree_update.nodes[6].id = 7;
2187 tree_update.nodes[6].child_ids = {11, 12};
2188 tree_update.nodes[6].AddState(ax::mojom::State::kIgnored);
2189
2190 tree_update.nodes[7].id = 8;
2191 tree_update.nodes[7].AddState(ax::mojom::State::kIgnored);
2192
2193 tree_update.nodes[8].id = 9;
2194
2195 tree_update.nodes[9].id = 10;
2196 tree_update.nodes[9].child_ids = {13};
2197 tree_update.nodes[9].AddState(ax::mojom::State::kIgnored);
2198
2199 tree_update.nodes[10].id = 11;
2200 tree_update.nodes[10].child_ids = {14, 15};
2201 tree_update.nodes[10].AddState(ax::mojom::State::kIgnored);
2202
2203 tree_update.nodes[11].id = 12;
2204
2205 tree_update.nodes[12].id = 13;
2206 tree_update.nodes[12].AddState(ax::mojom::State::kIgnored);
2207
2208 tree_update.nodes[13].id = 14;
2209
2210 tree_update.nodes[14].id = 15;
2211
2212 AXTree tree(tree_update);
2213 AXNode* root = tree.root();
2214
2215 // Test traversal
2216 // UnignoredChildren(root) = {5, 6, 14, 15, 12, 3, 4}
2217 AXNode::UnignoredChildIterator unignored_iterator =
2218 root->UnignoredChildrenBegin();
2219 EXPECT_EQ(5, unignored_iterator->id());
2220
2221 EXPECT_EQ(6, (++unignored_iterator)->id());
2222
2223 EXPECT_EQ(14, (++unignored_iterator)->id());
2224
2225 EXPECT_EQ(15, (++unignored_iterator)->id());
2226
2227 EXPECT_EQ(14, (--unignored_iterator)->id());
2228
2229 EXPECT_EQ(6, (--unignored_iterator)->id());
2230
2231 EXPECT_EQ(14, (++unignored_iterator)->id());
2232
2233 EXPECT_EQ(15, (++unignored_iterator)->id());
2234
2235 EXPECT_EQ(12, (++unignored_iterator)->id());
2236
2237 EXPECT_EQ(3, (++unignored_iterator)->id());
2238
2239 EXPECT_EQ(4, (++unignored_iterator)->id());
2240
2241 EXPECT_EQ(root->UnignoredChildrenEnd(), ++unignored_iterator);
2242
2243 // test empty list
2244 // UnignoredChildren(3) = {}
2245 AXNode* node3 = tree.GetFromId(3);
2246 unignored_iterator = node3->UnignoredChildrenBegin();
2247 EXPECT_EQ(node3->UnignoredChildrenEnd(), unignored_iterator);
2248
2249 // empty list from ignored node with no children
2250 // UnignoredChildren(8) = {}
2251 AXNode* node8 = tree.GetFromId(8);
2252 unignored_iterator = node8->UnignoredChildrenBegin();
2253 EXPECT_EQ(node8->UnignoredChildrenEnd(), unignored_iterator);
2254
2255 // empty list from ignored node with unignored children
2256 // UnignoredChildren(11) = {}
2257 AXNode* node11 = tree.GetFromId(11);
2258 unignored_iterator = node11->UnignoredChildrenBegin();
2259 EXPECT_EQ(14, unignored_iterator->id());
2260
2261 // Two UnignoredChildIterators from the same parent at the same position
2262 // should be equivalent, even in end position.
2263 unignored_iterator = root->UnignoredChildrenBegin();
2264 AXNode::UnignoredChildIterator unignored_iterator2 =
2265 root->UnignoredChildrenBegin();
2266 auto end = root->UnignoredChildrenEnd();
2267 while (unignored_iterator != end) {
2268 ASSERT_EQ(unignored_iterator, unignored_iterator2);
2269 ++unignored_iterator;
2270 ++unignored_iterator2;
2271 }
2272 ASSERT_EQ(unignored_iterator, unignored_iterator2);
2273}
glong glong end

◆ TEST() [212/215]

ui::TEST ( AXTreeTest  ,
UnignoredChildIteratorIgnoredContainerSiblings   
)

Definition at line 2050 of file ax_tree_unittest.cc.

2050 {
2051 AXTreeUpdate tree_update;
2052
2053 // RootWebArea #1
2054 // ++genericContainer IGNORED #2
2055 // ++++StaticText "text1" #3
2056 // ++genericContainer IGNORED #4
2057 // ++++StaticText "text2" #5
2058 // ++genericContainer IGNORED #6
2059 // ++++StaticText "text3" #7
2060
2061 tree_update.root_id = 1;
2062 tree_update.nodes.resize(7);
2063
2064 tree_update.nodes[0].id = 1;
2065 tree_update.nodes[0].role = ax::mojom::Role::kWebArea;
2066 tree_update.nodes[0].child_ids = {2, 4, 6};
2067
2068 tree_update.nodes[1].id = 2;
2069 tree_update.nodes[1].child_ids = {3};
2070 tree_update.nodes[1].role = ax::mojom::Role::kGenericContainer;
2071 tree_update.nodes[1].AddState(ax::mojom::State::kIgnored);
2072
2073 tree_update.nodes[2].id = 3;
2074 tree_update.nodes[2].role = ax::mojom::Role::kStaticText;
2075 tree_update.nodes[2].SetName("text1");
2076
2077 tree_update.nodes[3].id = 4;
2078 tree_update.nodes[3].child_ids = {5};
2079 tree_update.nodes[3].role = ax::mojom::Role::kGenericContainer;
2080 tree_update.nodes[3].AddState(ax::mojom::State::kIgnored);
2081
2082 tree_update.nodes[4].id = 5;
2083 tree_update.nodes[4].role = ax::mojom::Role::kStaticText;
2084 tree_update.nodes[4].SetName("text2");
2085
2086 tree_update.nodes[5].id = 6;
2087 tree_update.nodes[5].child_ids = {7};
2088 tree_update.nodes[5].role = ax::mojom::Role::kGenericContainer;
2089 tree_update.nodes[5].AddState(ax::mojom::State::kIgnored);
2090
2091 tree_update.nodes[6].id = 7;
2092 tree_update.nodes[6].role = ax::mojom::Role::kStaticText;
2093 tree_update.nodes[6].SetName("text3");
2094
2095 AXTree tree(tree_update);
2096
2097 {
2098 // Call unignored child iterator on root and iterate till the end, we should
2099 // get "text1", "text2", "text3" respectively because the sibling text nodes
2100 // share the same parent (i.e. root) as |unignored_iter|.
2101 AXNode* root = tree.root();
2102 AXNode::UnignoredChildIterator root_unignored_iter =
2103 root->UnignoredChildrenBegin();
2104 EXPECT_EQ(3, root_unignored_iter->id());
2105 EXPECT_EQ("text1", root_unignored_iter->GetStringAttribute(
2107
2108 EXPECT_EQ(5, (++root_unignored_iter)->id());
2109 EXPECT_EQ("text2",
2110 (*root_unignored_iter)
2111 .GetStringAttribute(ax::mojom::StringAttribute::kName));
2112
2113 EXPECT_EQ(7, (++root_unignored_iter)->id());
2114 EXPECT_EQ("text3", root_unignored_iter->GetStringAttribute(
2116 EXPECT_EQ(root->UnignoredChildrenEnd(), ++root_unignored_iter);
2117 }
2118
2119 {
2120 // Call unignored child iterator on the ignored generic container of "text1"
2121 // (id=2), When we iterate to the next of "text1", we should
2122 // reach the end because the sibling text node "text2" does not share the
2123 // same parent as |unignored_iter| of "text1".
2124 AXNode* text1_ignored_container = tree.GetFromId(2);
2125 AXNode::UnignoredChildIterator unignored_iter =
2126 text1_ignored_container->UnignoredChildrenBegin();
2127 EXPECT_EQ(3, unignored_iter->id());
2128 EXPECT_EQ("text1", unignored_iter->GetStringAttribute(
2130 // The next child of "text1" should be the end.
2131 EXPECT_EQ(text1_ignored_container->UnignoredChildrenEnd(),
2132 ++unignored_iter);
2133
2134 // Call unignored child iterator on the ignored generic container of "text2"
2135 // (id=4), When we iterate to the previous of "text2", we should
2136 // reach the end because the sibling text node "text1" does not share the
2137 // same parent as |unignored_iter| of "text2".
2138 AXNode* text2_ignored_container = tree.GetFromId(4);
2139 unignored_iter = text2_ignored_container->UnignoredChildrenBegin();
2140 EXPECT_EQ(5, unignored_iter->id());
2141 EXPECT_EQ("text2", unignored_iter->GetStringAttribute(
2143 // Decrement the iterator of "text2" should still remain on "text2" since
2144 // the beginning of iterator is "text2."
2145 --unignored_iter;
2146 EXPECT_EQ(5, unignored_iter->id());
2147 EXPECT_EQ("text2", unignored_iter->GetStringAttribute(
2149 }
2150}

◆ TEST() [213/215]

ui::TEST ( AXTreeTest  ,
UnignoredChildIteratorIncrementDecrementPastEnd   
)

Definition at line 1980 of file ax_tree_unittest.cc.

1980 {
1981 AXTreeUpdate tree_update;
1982
1983 // RootWebArea #1
1984 // ++StaticText "text1" #2
1985
1986 tree_update.root_id = 1;
1987 tree_update.nodes.resize(2);
1988
1989 tree_update.nodes[0].id = 1;
1990 tree_update.nodes[0].role = ax::mojom::Role::kWebArea;
1991 tree_update.nodes[0].child_ids = {2};
1992
1993 tree_update.nodes[1].id = 2;
1994 tree_update.nodes[1].role = ax::mojom::Role::kStaticText;
1995 tree_update.nodes[1].SetName("text1");
1996
1997 AXTree tree(tree_update);
1998 AXNode* root = tree.root();
1999
2000 {
2001 {
2002 AXNode::UnignoredChildIterator root_unignored_iter =
2003 root->UnignoredChildrenBegin();
2004 EXPECT_EQ(2, root_unignored_iter->id());
2005 EXPECT_EQ("text1", root_unignored_iter->GetStringAttribute(
2007
2008 // Call unignored child iterator on root and increment, we should reach
2009 // the end since there is only one iterator element.
2010 EXPECT_EQ(root->UnignoredChildrenEnd(), ++root_unignored_iter);
2011
2012 // We increment past the end, and we should still stay at the end.
2013 EXPECT_EQ(root->UnignoredChildrenEnd(), ++root_unignored_iter);
2014
2015 // When we decrement from the end, we should get the last iterator element
2016 // "text1".
2017 --root_unignored_iter;
2018 EXPECT_EQ(2, root_unignored_iter->id());
2019 EXPECT_EQ("text1", root_unignored_iter->GetStringAttribute(
2021 }
2022
2023 {
2024 AXNode::UnignoredChildIterator root_unignored_iter =
2025 root->UnignoredChildrenBegin();
2026 EXPECT_EQ(2, root_unignored_iter->id());
2027 EXPECT_EQ("text1", root_unignored_iter->GetStringAttribute(
2029
2030 // Call unignored child iterator on root and decrement from the beginning,
2031 // we should stay at the beginning.
2032 --root_unignored_iter;
2033 EXPECT_EQ(2, root_unignored_iter->id());
2034 EXPECT_EQ("text1", root_unignored_iter->GetStringAttribute(
2036
2037 // When we decrement past the beginning, we should still stay at the
2038 // beginning.
2039 --root_unignored_iter;
2040 EXPECT_EQ(2, root_unignored_iter->id());
2041 EXPECT_EQ("text1", root_unignored_iter->GetStringAttribute(
2043
2044 // We increment past the end, and we should still reach the end.
2045 EXPECT_EQ(root->UnignoredChildrenEnd(), ++root_unignored_iter);
2046 }
2047 }
2048}

◆ TEST() [214/215]

ui::TEST ( AXTreeTest  ,
UnignoredNextPreviousChild   
)

Definition at line 2365 of file ax_tree_unittest.cc.

2365 {
2366 AXTreeUpdate tree_update;
2367 // (i) => node is ignored
2368 // 1
2369 // |__________
2370 // | | |
2371 // 2(i) 3 4
2372 // |_______________________
2373 // | | | |
2374 // 5 6 7(i) 8(i)
2375 // | | |________
2376 // | | | |
2377 // 9 10(i) 11(i) 12
2378 // | |____
2379 // | | |
2380 // 13(i) 14 15
2381 // |
2382 // 16
2383 tree_update.root_id = 1;
2384 tree_update.nodes.resize(16);
2385 tree_update.nodes[0].id = 1;
2386 tree_update.nodes[0].child_ids = {2, 3, 4};
2387
2388 tree_update.nodes[1].id = 2;
2389 tree_update.nodes[1].child_ids = {5, 6, 7, 8};
2390 tree_update.nodes[1].AddState(ax::mojom::State::kIgnored);
2391
2392 tree_update.nodes[2].id = 3;
2393 tree_update.nodes[3].id = 4;
2394
2395 tree_update.nodes[4].id = 5;
2396 tree_update.nodes[4].child_ids = {9};
2397
2398 tree_update.nodes[5].id = 6;
2399 tree_update.nodes[5].child_ids = {10};
2400
2401 tree_update.nodes[6].id = 7;
2402 tree_update.nodes[6].child_ids = {11, 12};
2403 tree_update.nodes[6].AddState(ax::mojom::State::kIgnored);
2404
2405 tree_update.nodes[7].id = 8;
2406 tree_update.nodes[7].AddState(ax::mojom::State::kIgnored);
2407
2408 tree_update.nodes[8].id = 9;
2409
2410 tree_update.nodes[9].id = 10;
2411 tree_update.nodes[9].child_ids = {13};
2412 tree_update.nodes[9].AddState(ax::mojom::State::kIgnored);
2413
2414 tree_update.nodes[10].id = 11;
2415 tree_update.nodes[10].child_ids = {14, 15};
2416 tree_update.nodes[10].AddState(ax::mojom::State::kIgnored);
2417
2418 tree_update.nodes[11].id = 12;
2419
2420 tree_update.nodes[12].id = 13;
2421 tree_update.nodes[12].child_ids = {16};
2422 tree_update.nodes[12].AddState(ax::mojom::State::kIgnored);
2423
2424 tree_update.nodes[13].id = 14;
2425
2426 tree_update.nodes[14].id = 15;
2427
2428 tree_update.nodes[15].id = 16;
2429
2430 AXTree tree(tree_update);
2431
2432 EXPECT_EQ(nullptr, tree.GetFromId(1)->GetNextUnignoredSibling());
2433 EXPECT_EQ(nullptr, tree.GetFromId(1)->GetPreviousUnignoredSibling());
2434
2435 EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(2)->GetNextUnignoredSibling());
2436 EXPECT_EQ(nullptr, tree.GetFromId(2)->GetPreviousUnignoredSibling());
2437
2438 EXPECT_EQ(tree.GetFromId(4), tree.GetFromId(3)->GetNextUnignoredSibling());
2439 EXPECT_EQ(tree.GetFromId(12),
2440 tree.GetFromId(3)->GetPreviousUnignoredSibling());
2441
2442 EXPECT_EQ(nullptr, tree.GetFromId(4)->GetNextUnignoredSibling());
2443 EXPECT_EQ(tree.GetFromId(3),
2444 tree.GetFromId(4)->GetPreviousUnignoredSibling());
2445
2446 EXPECT_EQ(tree.GetFromId(6), tree.GetFromId(5)->GetNextUnignoredSibling());
2447 EXPECT_EQ(nullptr, tree.GetFromId(5)->GetPreviousUnignoredSibling());
2448
2449 EXPECT_EQ(tree.GetFromId(14), tree.GetFromId(6)->GetNextUnignoredSibling());
2450 EXPECT_EQ(tree.GetFromId(5),
2451 tree.GetFromId(6)->GetPreviousUnignoredSibling());
2452
2453 EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(7)->GetNextUnignoredSibling());
2454 EXPECT_EQ(tree.GetFromId(6),
2455 tree.GetFromId(7)->GetPreviousUnignoredSibling());
2456
2457 EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(8)->GetNextUnignoredSibling());
2458 EXPECT_EQ(tree.GetFromId(12),
2459 tree.GetFromId(8)->GetPreviousUnignoredSibling());
2460
2461 EXPECT_EQ(nullptr, tree.GetFromId(9)->GetNextUnignoredSibling());
2462 EXPECT_EQ(nullptr, tree.GetFromId(9)->GetPreviousUnignoredSibling());
2463
2464 EXPECT_EQ(nullptr, tree.GetFromId(10)->GetNextUnignoredSibling());
2465 EXPECT_EQ(nullptr, tree.GetFromId(10)->GetPreviousUnignoredSibling());
2466
2467 EXPECT_EQ(tree.GetFromId(12), tree.GetFromId(11)->GetNextUnignoredSibling());
2468 EXPECT_EQ(tree.GetFromId(6),
2469 tree.GetFromId(11)->GetPreviousUnignoredSibling());
2470
2471 EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(12)->GetNextUnignoredSibling());
2472 EXPECT_EQ(tree.GetFromId(15),
2473 tree.GetFromId(12)->GetPreviousUnignoredSibling());
2474
2475 EXPECT_EQ(nullptr, tree.GetFromId(13)->GetNextUnignoredSibling());
2476 EXPECT_EQ(nullptr, tree.GetFromId(13)->GetPreviousUnignoredSibling());
2477
2478 EXPECT_EQ(tree.GetFromId(15), tree.GetFromId(14)->GetNextUnignoredSibling());
2479 EXPECT_EQ(tree.GetFromId(6),
2480 tree.GetFromId(14)->GetPreviousUnignoredSibling());
2481
2482 EXPECT_EQ(tree.GetFromId(12), tree.GetFromId(15)->GetNextUnignoredSibling());
2483 EXPECT_EQ(tree.GetFromId(14),
2484 tree.GetFromId(15)->GetPreviousUnignoredSibling());
2485
2486 EXPECT_EQ(nullptr, tree.GetFromId(16)->GetNextUnignoredSibling());
2487 EXPECT_EQ(nullptr, tree.GetFromId(16)->GetPreviousUnignoredSibling());
2488}

◆ TEST() [215/215]

ui::TEST ( AXTreeTest  ,
UnignoredSelection   
)

Definition at line 2793 of file ax_tree_unittest.cc.

2793 {
2794 AXTreeUpdate tree_update;
2795 // (i) => node is ignored
2796 // 1
2797 // |__________
2798 // | | |
2799 // 2(i) 3 4
2800 // |_______________________
2801 // | | | |
2802 // 5 6 7(i) 8(i)
2803 // | | |________
2804 // | | | |
2805 // 9 10(i) 11(i) 12
2806 // | |____
2807 // | | |
2808 // 13(i) 14 15
2809 // |
2810 // 16
2811 // Unignored Tree (conceptual)
2812 // 1
2813 // |______________________
2814 // | | | | | | |
2815 // 5 6 14 15 12 3 4
2816 // | |
2817 // 9 16
2818 tree_update.has_tree_data = true;
2820 tree_update.root_id = 1;
2821 tree_update.nodes.resize(16);
2822 tree_update.nodes[0].id = 1;
2823 tree_update.nodes[0].role = ax::mojom::Role::kGenericContainer;
2824 tree_update.nodes[0].child_ids = {2, 3, 4};
2825
2826 tree_update.nodes[1].id = 2;
2827 tree_update.nodes[1].child_ids = {5, 6, 7, 8};
2828 tree_update.nodes[1].role = ax::mojom::Role::kGenericContainer;
2829 tree_update.nodes[1].AddState(ax::mojom::State::kIgnored);
2830
2831 tree_update.nodes[2].id = 3;
2832 tree_update.nodes[2].role = ax::mojom::Role::kStaticText;
2833 tree_update.nodes[2].SetName("text");
2834
2835 tree_update.nodes[3].id = 4;
2836 tree_update.nodes[3].role = ax::mojom::Role::kStaticText;
2837 tree_update.nodes[3].SetName("text");
2838
2839 tree_update.nodes[4].id = 5;
2840 tree_update.nodes[4].role = ax::mojom::Role::kGenericContainer;
2841 tree_update.nodes[4].child_ids = {9};
2842
2843 tree_update.nodes[5].id = 6;
2844 tree_update.nodes[5].role = ax::mojom::Role::kGenericContainer;
2845 tree_update.nodes[5].child_ids = {10};
2846
2847 tree_update.nodes[6].id = 7;
2848 tree_update.nodes[6].child_ids = {11, 12};
2849 tree_update.nodes[6].role = ax::mojom::Role::kGenericContainer;
2850 tree_update.nodes[6].AddState(ax::mojom::State::kIgnored);
2851
2852 tree_update.nodes[7].id = 8;
2853 tree_update.nodes[7].role = ax::mojom::Role::kGenericContainer;
2854 tree_update.nodes[7].AddState(ax::mojom::State::kIgnored);
2855
2856 tree_update.nodes[8].id = 9;
2857 tree_update.nodes[8].role = ax::mojom::Role::kStaticText;
2858 tree_update.nodes[8].SetName("text");
2859
2860 tree_update.nodes[9].id = 10;
2861 tree_update.nodes[9].child_ids = {13};
2862 tree_update.nodes[9].role = ax::mojom::Role::kGenericContainer;
2863 tree_update.nodes[9].AddState(ax::mojom::State::kIgnored);
2864
2865 tree_update.nodes[10].id = 11;
2866 tree_update.nodes[10].child_ids = {14, 15};
2867 tree_update.nodes[10].role = ax::mojom::Role::kGenericContainer;
2868 tree_update.nodes[10].AddState(ax::mojom::State::kIgnored);
2869
2870 tree_update.nodes[11].id = 12;
2871 tree_update.nodes[11].role = ax::mojom::Role::kStaticText;
2872 tree_update.nodes[11].SetName("text");
2873
2874 tree_update.nodes[12].id = 13;
2875 tree_update.nodes[12].child_ids = {16};
2876 tree_update.nodes[12].role = ax::mojom::Role::kGenericContainer;
2877 tree_update.nodes[12].AddState(ax::mojom::State::kIgnored);
2878
2879 tree_update.nodes[13].id = 14;
2880 tree_update.nodes[13].role = ax::mojom::Role::kStaticText;
2881 tree_update.nodes[13].SetName("text");
2882
2883 tree_update.nodes[14].id = 15;
2884 tree_update.nodes[14].role = ax::mojom::Role::kStaticText;
2885 tree_update.nodes[14].SetName("text");
2886
2887 tree_update.nodes[15].id = 16;
2888 tree_update.nodes[15].role = ax::mojom::Role::kStaticText;
2889 tree_update.nodes[15].SetName("text");
2890
2891 TestAXTreeManager test_ax_tree_manager(std::make_unique<AXTree>(tree_update));
2892 AXTree::Selection unignored_selection =
2893 test_ax_tree_manager.GetTree()->GetUnignoredSelection();
2894
2895 EXPECT_EQ(AXNode::kInvalidAXID, unignored_selection.anchor_object_id);
2896 EXPECT_EQ(-1, unignored_selection.anchor_offset);
2897 EXPECT_EQ(AXNode::kInvalidAXID, unignored_selection.focus_object_id);
2898 EXPECT_EQ(-1, unignored_selection.focus_offset);
2899 struct SelectionData {
2900 int32_t anchor_id;
2901 int32_t anchor_offset;
2902 int32_t focus_id;
2903 int32_t focus_offset;
2904 };
2905
2906 SelectionData input = {1, 0, 1, 0};
2907 SelectionData expected = {9, 0, 9, 0};
2908 TEST_SELECTION(tree_update, test_ax_tree_manager.GetTree(), input, expected);
2909
2910 input = {1, 0, 2, 2};
2911 expected = {9, 0, 14, 0};
2912 TEST_SELECTION(tree_update, test_ax_tree_manager.GetTree(), input, expected);
2913
2914 input = {2, 1, 5, 0};
2915 expected = {16, 0, 5, 0};
2916 TEST_SELECTION(tree_update, test_ax_tree_manager.GetTree(), input, expected);
2917
2918 input = {5, 0, 9, 0};
2919 expected = {5, 0, 9, 0};
2920 TEST_SELECTION(tree_update, test_ax_tree_manager.GetTree(), input, expected);
2921
2922 input = {9, 0, 6, 0};
2923 expected = {9, 0, 16, 0};
2924 TEST_SELECTION(tree_update, test_ax_tree_manager.GetTree(), input, expected);
2925
2926 input = {6, 0, 10, 0};
2927 expected = {16, 0, 16, 0};
2928 TEST_SELECTION(tree_update, test_ax_tree_manager.GetTree(), input, expected);
2929
2930 input = {10, 0, 13, 0};
2931 expected = {16, 0, 16, 0};
2932 TEST_SELECTION(tree_update, test_ax_tree_manager.GetTree(), input, expected);
2933
2934 input = {13, 0, 16, 0};
2935 expected = {16, 0, 16, 0};
2936 TEST_SELECTION(tree_update, test_ax_tree_manager.GetTree(), input, expected);
2937
2938 input = {16, 0, 7, 0};
2939 expected = {16, 0, 14, 0};
2940 TEST_SELECTION(tree_update, test_ax_tree_manager.GetTree(), input, expected);
2941
2942 input = {7, 0, 11, 0};
2943 expected = {14, 0, 14, 0};
2944 TEST_SELECTION(tree_update, test_ax_tree_manager.GetTree(), input, expected);
2945
2946 input = {11, 1, 14, 2};
2947 expected = {15, 0, 14, 2};
2948 TEST_SELECTION(tree_update, test_ax_tree_manager.GetTree(), input, expected);
2949
2950 input = {14, 2, 15, 3};
2951 expected = {14, 2, 15, 3};
2952 TEST_SELECTION(tree_update, test_ax_tree_manager.GetTree(), input, expected);
2953
2954 input = {15, 0, 12, 0};
2955 expected = {15, 0, 12, 0};
2956 TEST_SELECTION(tree_update, test_ax_tree_manager.GetTree(), input, expected);
2957
2958 input = {12, 0, 8, 0};
2959 expected = {12, 0, 3, 0};
2960 TEST_SELECTION(tree_update, test_ax_tree_manager.GetTree(), input, expected);
2961
2962 input = {8, 0, 3, 0};
2963 expected = {12, 4, 3, 0};
2964 TEST_SELECTION(tree_update, test_ax_tree_manager.GetTree(), input, expected);
2965
2966 input = {3, 0, 4, 0};
2967 expected = {3, 0, 4, 0};
2968 TEST_SELECTION(tree_update, test_ax_tree_manager.GetTree(), input, expected);
2969
2970 input = {4, 0, 4, 0};
2971 expected = {4, 0, 4, 0};
2972 TEST_SELECTION(tree_update, test_ax_tree_manager.GetTree(), input, expected);
2973}
#define TEST_SELECTION(tree_update, tree, input, expected)
static AXTreeID CreateNewAXTreeID()
Definition: ax_tree_id.cc:47

◆ TEST_F() [1/325]

ui::TEST_F ( AXFragmentRootTest  ,
DISABLED_TestUIAElementProviderFromPoint   
)

Definition at line 280 of file ax_fragment_root_win_unittest.cc.

280 {
281 AXNodeData root_data;
282 root_data.id = 1;
283 root_data.relative_bounds.bounds = gfx::RectF(0, 0, 80, 80);
284
285 AXNodeData element1_data;
286 element1_data.id = 2;
287 element1_data.relative_bounds.bounds = gfx::RectF(0, 0, 50, 50);
288 root_data.child_ids.push_back(element1_data.id);
289
290 AXNodeData element2_data;
291 element2_data.id = 3;
292 element2_data.relative_bounds.bounds = gfx::RectF(0, 50, 30, 30);
293 root_data.child_ids.push_back(element2_data.id);
294
295 Init(root_data, element1_data, element2_data);
296 InitFragmentRoot();
297
298 AXNode* root_node = GetRootAsAXNode();
299 AXNode* element1_node = root_node->children()[0];
300 AXNode* element2_node = root_node->children()[1];
301
302 ComPtr<IRawElementProviderFragmentRoot> fragment_root_prov(GetFragmentRoot());
303 ComPtr<IRawElementProviderFragment> root_provider(
304 GetRootIRawElementProviderFragment());
305 ComPtr<IRawElementProviderFragment> element1_provider =
306 QueryInterfaceFromNode<IRawElementProviderFragment>(element1_node);
307 ComPtr<IRawElementProviderFragment> element2_provider =
308 QueryInterfaceFromNode<IRawElementProviderFragment>(element2_node);
309
310 ComPtr<IRawElementProviderFragment> provider_from_point;
311 EXPECT_HRESULT_SUCCEEDED(fragment_root_prov->ElementProviderFromPoint(
312 23, 31, &provider_from_point));
313 EXPECT_EQ(element1_provider.Get(), provider_from_point.Get());
314
315 EXPECT_HRESULT_SUCCEEDED(fragment_root_prov->ElementProviderFromPoint(
316 23, 67, &provider_from_point));
317 EXPECT_EQ(element2_provider.Get(), provider_from_point.Get());
318
319 EXPECT_HRESULT_SUCCEEDED(fragment_root_prov->ElementProviderFromPoint(
320 47, 67, &provider_from_point));
321 EXPECT_EQ(root_provider.Get(), provider_from_point.Get());
322
323 // This is on node 1 with scale factor of 1.5.
324 std::unique_ptr<base::AutoReset<float>> scale_factor_reset =
325 TestAXNodeWrapper::SetScaleFactor(1.5);
326 EXPECT_HRESULT_SUCCEEDED(fragment_root_prov->ElementProviderFromPoint(
327 60, 60, &provider_from_point));
328 EXPECT_EQ(element1_provider.Get(), provider_from_point.Get());
329}
const std::vector< AXNode * > & children() const
Definition: ax_node.h:113
void Init()
AXRelativeBounds relative_bounds
Definition: ax_node_data.h:293

◆ TEST_F() [2/325]

ui::TEST_F ( AXFragmentRootTest  ,
TestChildAtIndex   
)

Definition at line 425 of file ax_fragment_root_win_unittest.cc.

425 {
427 root.id = 1;
428 Init(root);
429 InitFragmentRoot();
430
431 gfx::NativeViewAccessible native_view_accessible =
432 AXPlatformNodeFromNode(GetRootAsAXNode())->GetNativeViewAccessible();
433 AXPlatformNodeDelegate* fragment_root = ax_fragment_root_.get();
434 EXPECT_EQ(native_view_accessible, fragment_root->ChildAtIndex(0));
435 EXPECT_EQ(nullptr, fragment_root->ChildAtIndex(1));
436
437 test_fragment_root_delegate_->child_ = nullptr;
438 EXPECT_EQ(nullptr, fragment_root->ChildAtIndex(0));
439}
virtual gfx::NativeViewAccessible ChildAtIndex(int index)=0

◆ TEST_F() [3/325]

ui::TEST_F ( AXFragmentRootTest  ,
TestFragmentRootMap   
)

Definition at line 672 of file ax_fragment_root_win_unittest.cc.

672 {
674 root.id = 1;
675 Init(root);
676
677 // There should be nothing in the map before we create a fragment root.
678 // Call GetForAcceleratedWidget() first to ensure that querying for a
679 // fragment root doesn't inadvertently create an empty entry in the map
680 // (https://crbug.com/1071185).
681 EXPECT_EQ(nullptr, AXFragmentRootWin::GetForAcceleratedWidget(
682 gfx::kMockAcceleratedWidget));
683 EXPECT_EQ(nullptr, AXFragmentRootWin::GetFragmentRootParentOf(
684 GetRootIAccessible().Get()));
685
686 // After initializing a fragment root, we should be able to retrieve it using
687 // its accelerated widget, or as the parent of its child.
688 InitFragmentRoot();
689 EXPECT_EQ(ax_fragment_root_.get(), AXFragmentRootWin::GetForAcceleratedWidget(
690 gfx::kMockAcceleratedWidget));
691 EXPECT_EQ(ax_fragment_root_.get(), AXFragmentRootWin::GetFragmentRootParentOf(
692 GetRootIAccessible().Get()));
693
694 // After deleting a fragment root, it should no longer be reachable from the
695 // map.
696 ax_fragment_root_.reset();
697 EXPECT_EQ(nullptr, AXFragmentRootWin::GetForAcceleratedWidget(
698 gfx::kMockAcceleratedWidget));
699 EXPECT_EQ(nullptr, AXFragmentRootWin::GetFragmentRootParentOf(
700 GetRootIAccessible().Get()));
701}

◆ TEST_F() [4/325]

ui::TEST_F ( AXFragmentRootTest  ,
TestGetChildCount   
)

Definition at line 412 of file ax_fragment_root_win_unittest.cc.

412 {
414 root.id = 1;
415 Init(root);
416 InitFragmentRoot();
417
418 AXPlatformNodeDelegate* fragment_root = ax_fragment_root_.get();
419 EXPECT_EQ(1, fragment_root->GetChildCount());
420
421 test_fragment_root_delegate_->child_ = nullptr;
422 EXPECT_EQ(0, fragment_root->GetChildCount());
423}
virtual int GetChildCount() const =0

◆ TEST_F() [5/325]

ui::TEST_F ( AXFragmentRootTest  ,
TestGetParent   
)

Definition at line 441 of file ax_fragment_root_win_unittest.cc.

441 {
443 root.id = 1;
444 Init(root);
445 InitFragmentRoot();
446
447 AXPlatformNodeDelegate* fragment_root = ax_fragment_root_.get();
448 EXPECT_EQ(nullptr, fragment_root->GetParent());
449
450 gfx::NativeViewAccessible native_view_accessible =
451 AXPlatformNodeFromNode(GetRootAsAXNode())->GetNativeViewAccessible();
452 test_fragment_root_delegate_->parent_ = native_view_accessible;
453 EXPECT_EQ(native_view_accessible, fragment_root->GetParent());
454}
virtual gfx::NativeViewAccessible GetParent()=0

◆ TEST_F() [6/325]

ui::TEST_F ( AXFragmentRootTest  ,
TestGetPropertyValue   
)

Definition at line 456 of file ax_fragment_root_win_unittest.cc.

456 {
458 root.id = 1;
459 Init(root);
460 InitFragmentRoot();
461
462 ComPtr<IRawElementProviderSimple> root_provider;
463 ax_fragment_root_->GetNativeViewAccessible()->QueryInterface(
464 IID_PPV_ARGS(&root_provider));
465
466 // IsControlElement and IsContentElement should follow the setting on the
467 // fragment root delegate.
468 test_fragment_root_delegate_->is_control_element_ = true;
470 EXPECT_HRESULT_SUCCEEDED(root_provider->GetPropertyValue(
471 UIA_IsControlElementPropertyId, result.Receive()));
472 EXPECT_EQ(result.type(), VT_BOOL);
473 EXPECT_EQ(result.ptr()->boolVal, VARIANT_TRUE);
474 EXPECT_HRESULT_SUCCEEDED(root_provider->GetPropertyValue(
475 UIA_IsContentElementPropertyId, result.Receive()));
476 EXPECT_EQ(result.type(), VT_BOOL);
477 EXPECT_EQ(result.ptr()->boolVal, VARIANT_TRUE);
478
479 test_fragment_root_delegate_->is_control_element_ = false;
480 EXPECT_HRESULT_SUCCEEDED(root_provider->GetPropertyValue(
481 UIA_IsControlElementPropertyId, result.Receive()));
482 EXPECT_EQ(result.type(), VT_BOOL);
483 EXPECT_EQ(result.ptr()->boolVal, VARIANT_FALSE);
484 EXPECT_HRESULT_SUCCEEDED(root_provider->GetPropertyValue(
485 UIA_IsContentElementPropertyId, result.Receive()));
486 EXPECT_EQ(result.type(), VT_BOOL);
487 EXPECT_EQ(result.ptr()->boolVal, VARIANT_FALSE);
488
489 // Other properties should return VT_EMPTY.
490 EXPECT_HRESULT_SUCCEEDED(root_provider->GetPropertyValue(
491 UIA_ControlTypePropertyId, result.Receive()));
492 EXPECT_EQ(result.type(), VT_EMPTY);
493}
GAsyncResult * result

◆ TEST_F() [7/325]

ui::TEST_F ( AXFragmentRootTest  ,
TestUIAErrorHandling   
)

Definition at line 372 of file ax_fragment_root_win_unittest.cc.

372 {
374 root.id = 1;
375 Init(root);
376 InitFragmentRoot();
377
378 ComPtr<IRawElementProviderSimple> simple_provider =
379 GetRootIRawElementProviderSimple();
380 ComPtr<IRawElementProviderFragment> fragment_provider =
381 GetRootIRawElementProviderFragment();
382 ComPtr<IRawElementProviderFragmentRoot> fragment_root_provider =
383 GetFragmentRoot();
384
385 SetTree(std::make_unique<AXTree>());
386 ax_fragment_root_.reset(nullptr);
387
388 ComPtr<IRawElementProviderSimple> returned_simple_provider;
389 ComPtr<IRawElementProviderFragment> returned_fragment_provider;
390 ComPtr<IRawElementProviderFragmentRoot> returned_fragment_root_provider;
391 base::win::ScopedSafearray returned_runtime_id;
392
393 EXPECT_EQ(
394 static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
395 simple_provider->get_HostRawElementProvider(&returned_simple_provider));
396
397 EXPECT_EQ(
398 static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
399 fragment_provider->get_FragmentRoot(&returned_fragment_root_provider));
400
401 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
402 fragment_provider->GetRuntimeId(returned_runtime_id.Receive()));
403
404 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
405 fragment_root_provider->ElementProviderFromPoint(
406 67, 23, &returned_fragment_provider));
407
408 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
409 fragment_root_provider->GetFocus(&returned_fragment_provider));
410}

◆ TEST_F() [8/325]

ui::TEST_F ( AXFragmentRootTest  ,
TestUIAGetFocus   
)

Definition at line 331 of file ax_fragment_root_win_unittest.cc.

331 {
332 AXNodeData root_data;
333 root_data.id = 1;
334
335 AXNodeData element1_data;
336 element1_data.id = 2;
337 root_data.child_ids.push_back(element1_data.id);
338
339 AXNodeData element2_data;
340 element2_data.id = 3;
341 root_data.child_ids.push_back(element2_data.id);
342
343 Init(root_data, element1_data, element2_data);
344 InitFragmentRoot();
345
346 AXNode* root_node = GetRootAsAXNode();
347 AXNode* element1_node = root_node->children()[0];
348 AXNode* element2_node = root_node->children()[1];
349
350 ComPtr<IRawElementProviderFragmentRoot> fragment_root_prov(GetFragmentRoot());
351 ComPtr<IRawElementProviderFragment> root_provider(
352 GetRootIRawElementProviderFragment());
353 ComPtr<IRawElementProviderFragment> element1_provider =
354 QueryInterfaceFromNode<IRawElementProviderFragment>(element1_node);
355 ComPtr<IRawElementProviderFragment> element2_provider =
356 QueryInterfaceFromNode<IRawElementProviderFragment>(element2_node);
357
358 ComPtr<IRawElementProviderFragment> focused_fragment;
359 EXPECT_HRESULT_SUCCEEDED(root_provider->SetFocus());
360 EXPECT_HRESULT_SUCCEEDED(fragment_root_prov->GetFocus(&focused_fragment));
361 EXPECT_EQ(root_provider.Get(), focused_fragment.Get());
362
363 EXPECT_HRESULT_SUCCEEDED(element1_provider->SetFocus());
364 EXPECT_HRESULT_SUCCEEDED(fragment_root_prov->GetFocus(&focused_fragment));
365 EXPECT_EQ(element1_provider.Get(), focused_fragment.Get());
366
367 EXPECT_HRESULT_SUCCEEDED(element2_provider->SetFocus());
368 EXPECT_HRESULT_SUCCEEDED(fragment_root_prov->GetFocus(&focused_fragment));
369 EXPECT_EQ(element2_provider.Get(), focused_fragment.Get());
370}

◆ TEST_F() [9/325]

ui::TEST_F ( AXFragmentRootTest  ,
TestUIAGetFragmentRoot   
)

Definition at line 263 of file ax_fragment_root_win_unittest.cc.

263 {
265 root.id = 1;
266 Init(root);
267 InitFragmentRoot();
268
269 ComPtr<IRawElementProviderFragmentRoot> expected_fragment_root =
270 GetFragmentRoot();
271 ComPtr<IRawElementProviderFragment> fragment_provider;
272 expected_fragment_root.As(&fragment_provider);
273
274 ComPtr<IRawElementProviderFragmentRoot> actual_fragment_root;
275 EXPECT_HRESULT_SUCCEEDED(
276 fragment_provider->get_FragmentRoot(&actual_fragment_root));
277 EXPECT_EQ(expected_fragment_root.Get(), actual_fragment_root.Get());
278}

◆ TEST_F() [10/325]

ui::TEST_F ( AXFragmentRootTest  ,
TestUIAMultipleFragmentRoots   
)

Definition at line 495 of file ax_fragment_root_win_unittest.cc.

495 {
496 // Consider the following platform-neutral tree:
497 //
498 // N1
499 // _____/ \_____
500 // / \
501 // N2---N3---N4---N5
502 // / \ / \
503 // N6---N7 N8---N9
504 //
505 // N3 and N5 are nodes for which we need a fragment root. This will correspond
506 // to the following tree in UIA:
507 //
508 // U1
509 // _____/ \_____
510 // / \
511 // U2---R3---U4---R5
512 // | |
513 // U3 U5
514 // / \ / \
515 // U6---U7 U8---U9
516
517 ui::AXNodeData top_fragment_root_n1;
518 top_fragment_root_n1.id = 1;
519
520 ui::AXNodeData sibling_n2;
521 sibling_n2.id = 2;
522
523 ui::AXNodeData child_fragment_root_n3;
524 child_fragment_root_n3.id = 3;
525
526 ui::AXNodeData sibling_n6;
527 sibling_n6.id = 6;
528 ui::AXNodeData sibling_n7;
529 sibling_n7.id = 7;
530
531 child_fragment_root_n3.child_ids = {6, 7};
532
533 ui::AXNodeData sibling_n4;
534 sibling_n4.id = 4;
535
536 ui::AXNodeData child_fragment_root_n5;
537 child_fragment_root_n5.id = 5;
538
539 ui::AXNodeData sibling_n8;
540 sibling_n8.id = 8;
541 ui::AXNodeData sibling_n9;
542 sibling_n9.id = 9;
543
544 child_fragment_root_n5.child_ids = {8, 9};
545 top_fragment_root_n1.child_ids = {2, 3, 4, 5};
546
548 update.has_tree_data = true;
549 update.root_id = top_fragment_root_n1.id;
550 update.nodes = {top_fragment_root_n1,
551 sibling_n2,
552 child_fragment_root_n3,
553 sibling_n6,
554 sibling_n7,
555 sibling_n4,
556 child_fragment_root_n5,
557 sibling_n8,
558 sibling_n9};
559 update.tree_data.tree_id = ui::AXTreeID::CreateNewAXTreeID();
560
561 Init(update);
562 InitFragmentRoot();
563
564 AXNode* root_node = GetRootAsAXNode();
565
566 // Set up other fragment roots
567 AXNode* child_fragment_root_n3_node = root_node->children()[1];
568 std::unique_ptr<TestFragmentRootDelegate> n3_fragment_root_delegate =
569 std::make_unique<TestFragmentRootDelegate>();
570 std::unique_ptr<AXFragmentRootWin> n3_fragment_root(InitNodeAsFragmentRoot(
571 child_fragment_root_n3_node, n3_fragment_root_delegate.get()));
572
573 AXNode* child_fragment_root_n5_node = root_node->children()[3];
574 std::unique_ptr<TestFragmentRootDelegate> n5_fragment_root_delegate =
575 std::make_unique<TestFragmentRootDelegate>();
576 std::unique_ptr<AXFragmentRootWin> n5_fragment_root(InitNodeAsFragmentRoot(
577 child_fragment_root_n5_node, n5_fragment_root_delegate.get()));
578
579 // Test navigation from root fragment
580 ComPtr<IRawElementProviderFragmentRoot> root_fragment_root =
581 GetFragmentRoot();
582 ComPtr<IRawElementProviderFragment> root_fragment;
583 root_fragment_root.As(&root_fragment);
584
585 ComPtr<IRawElementProviderFragment> test_fragment;
586 EXPECT_HRESULT_SUCCEEDED(
587 root_fragment->Navigate(NavigateDirection_Parent, &test_fragment));
588 EXPECT_EQ(nullptr, test_fragment.Get());
589
590 EXPECT_HRESULT_SUCCEEDED(
591 root_fragment->Navigate(NavigateDirection_NextSibling, &test_fragment));
592 EXPECT_EQ(nullptr, test_fragment.Get());
593
594 EXPECT_HRESULT_SUCCEEDED(root_fragment->Navigate(
595 NavigateDirection_PreviousSibling, &test_fragment));
596 EXPECT_EQ(nullptr, test_fragment.Get());
597
598 EXPECT_HRESULT_SUCCEEDED(
599 root_fragment->Navigate(NavigateDirection_FirstChild, &test_fragment));
600 ComPtr<IUnknown> root_child_unknown = test_fragment_root_delegate_->child_;
601 ComPtr<IRawElementProviderFragment> root_child_fragment;
602 root_child_unknown.As(&root_child_fragment);
603 EXPECT_EQ(root_child_fragment.Get(), test_fragment.Get());
604
605 EXPECT_HRESULT_SUCCEEDED(
606 root_fragment->Navigate(NavigateDirection_LastChild, &test_fragment));
607 EXPECT_EQ(root_child_fragment.Get(), test_fragment.Get());
608
609 // Test navigation from first child root (R3)
610 ComPtr<IRawElementProviderFragmentRoot> n3_fragment_root_provider;
611 n3_fragment_root->GetNativeViewAccessible()->QueryInterface(
612 IID_PPV_ARGS(&n3_fragment_root_provider));
613
614 ComPtr<IRawElementProviderFragment> n3_fragment;
615 n3_fragment_root_provider.As(&n3_fragment);
616 EXPECT_HRESULT_SUCCEEDED(
617 n3_fragment->Navigate(NavigateDirection_Parent, &test_fragment));
618 EXPECT_EQ(root_child_fragment.Get(), test_fragment.Get());
619
620 AXNode* sibling_n2_node = root_node->children()[0];
621 EXPECT_HRESULT_SUCCEEDED(
622 n3_fragment->Navigate(NavigateDirection_PreviousSibling, &test_fragment));
623 EXPECT_EQ(IRawElementProviderFragmentFromNode(sibling_n2_node).Get(),
624 test_fragment.Get());
625
626 AXNode* sibling_n4_node = root_node->children()[2];
627 EXPECT_HRESULT_SUCCEEDED(
628 n3_fragment->Navigate(NavigateDirection_NextSibling, &test_fragment));
629 EXPECT_EQ(IRawElementProviderFragmentFromNode(sibling_n4_node).Get(),
630 test_fragment.Get());
631
632 EXPECT_HRESULT_SUCCEEDED(
633 n3_fragment->Navigate(NavigateDirection_FirstChild, &test_fragment));
634 EXPECT_EQ(
635 IRawElementProviderFragmentFromNode(child_fragment_root_n3_node).Get(),
636 test_fragment.Get());
637 EXPECT_HRESULT_SUCCEEDED(
638 n3_fragment->Navigate(NavigateDirection_LastChild, &test_fragment));
639 EXPECT_EQ(
640 IRawElementProviderFragmentFromNode(child_fragment_root_n3_node).Get(),
641 test_fragment.Get());
642
643 // Test navigation from second child root (R5)
644 ComPtr<IRawElementProviderFragmentRoot> n5_fragment_root_provider;
645 n5_fragment_root->GetNativeViewAccessible()->QueryInterface(
646 IID_PPV_ARGS(&n5_fragment_root_provider));
647
648 ComPtr<IRawElementProviderFragment> n5_fragment;
649 n5_fragment_root_provider.As(&n5_fragment);
650 EXPECT_HRESULT_SUCCEEDED(
651 n5_fragment->Navigate(NavigateDirection_Parent, &test_fragment));
652 EXPECT_EQ(root_child_fragment.Get(), test_fragment.Get());
653 EXPECT_HRESULT_SUCCEEDED(
654 n5_fragment->Navigate(NavigateDirection_NextSibling, &test_fragment));
655 EXPECT_EQ(nullptr, test_fragment.Get());
656 EXPECT_HRESULT_SUCCEEDED(
657 n5_fragment->Navigate(NavigateDirection_PreviousSibling, &test_fragment));
658 EXPECT_EQ(IRawElementProviderFragmentFromNode(sibling_n4_node).Get(),
659 test_fragment.Get());
660 EXPECT_HRESULT_SUCCEEDED(
661 n5_fragment->Navigate(NavigateDirection_FirstChild, &test_fragment));
662 EXPECT_EQ(
663 IRawElementProviderFragmentFromNode(child_fragment_root_n5_node).Get(),
664 test_fragment.Get());
665 EXPECT_HRESULT_SUCCEEDED(
666 n5_fragment->Navigate(NavigateDirection_LastChild, &test_fragment));
667 EXPECT_EQ(
668 IRawElementProviderFragmentFromNode(child_fragment_root_n5_node).Get(),
669 test_fragment.Get());
670}

◆ TEST_F() [11/325]

ui::TEST_F ( AXFragmentRootTest  ,
UIAFindItemByPropertyUniqueId   
)

Definition at line 45 of file ax_fragment_root_win_unittest.cc.

45 {
47 root.id = 1;
49 root.SetName("root");
50 root.child_ids = {2, 3};
51
52 AXNodeData text1;
53 text1.id = 2;
55 text1.SetName("text1");
56
57 AXNodeData button;
58 button.id = 3;
59 button.role = ax::mojom::Role::kButton;
60 button.SetName("button");
61 button.child_ids = {4};
62
63 AXNodeData text2;
64 text2.id = 4;
66 text2.SetName("text2");
67
68 Init(root, text1, button, text2);
69 InitFragmentRoot();
70
71 ComPtr<IRawElementProviderSimple> root_raw_element_provider_simple;
72 ax_fragment_root_->GetNativeViewAccessible()->QueryInterface(
73 IID_PPV_ARGS(&root_raw_element_provider_simple));
74 ComPtr<IRawElementProviderSimple> text1_raw_element_provider_simple =
75 GetIRawElementProviderSimpleFromChildIndex(0);
76 ComPtr<IRawElementProviderSimple> button_raw_element_provider_simple =
77 GetIRawElementProviderSimpleFromChildIndex(1);
78
79 AXNode* text1_node = GetRootAsAXNode()->children()[0];
80 AXNode* button_node = GetRootAsAXNode()->children()[1];
81
82 ComPtr<IItemContainerProvider> item_container_provider;
83 EXPECT_HRESULT_SUCCEEDED(root_raw_element_provider_simple->GetPatternProvider(
84 UIA_ItemContainerPatternId, &item_container_provider));
85 ASSERT_NE(nullptr, item_container_provider.Get());
86
87 ScopedVariant unique_id_variant;
88 int32_t unique_id;
89 ComPtr<IRawElementProviderSimple> result;
90
91 // When |start_after_element| is an invalid element, we should fail at finding
92 // the item.
93 {
94 unique_id = AXPlatformNodeFromNode(GetRootAsAXNode())->GetUniqueId();
95 unique_id_variant.Set(SysAllocString(reinterpret_cast<const wchar_t*>(
96 base::NumberToString16(-unique_id).c_str())));
97
98 ComPtr<IRawElementProviderSimple> invalid_element_provider_simple;
99 EXPECT_HRESULT_SUCCEEDED(
100 MockIRawElementProviderSimple::CreateMockIRawElementProviderSimple(
101 &invalid_element_provider_simple));
102
103 EXPECT_HRESULT_FAILED(item_container_provider->FindItemByProperty(
104 invalid_element_provider_simple.Get(),
105 UiaRegistrarWin::GetInstance().GetUiaUniqueIdPropertyId(),
106 unique_id_variant, &result));
107 result.Reset();
108 unique_id_variant.Release();
109 }
110
111 // Fetch the AxUniqueId of "root", and verify we can retrieve its
112 // corresponding IRawElementProviderSimple through FindItemByProperty().
113 {
114 unique_id = AXPlatformNodeFromNode(GetRootAsAXNode())->GetUniqueId();
115 unique_id_variant.Set(SysAllocString(reinterpret_cast<const wchar_t*>(
116 base::NumberToString16(-unique_id).c_str())));
117
118 // When |start_after_element| of FindItemByProperty() is nullptr, we should
119 // be able to find "text1".
120 EXPECT_HRESULT_SUCCEEDED(item_container_provider->FindItemByProperty(
121 nullptr, UiaRegistrarWin::GetInstance().GetUiaUniqueIdPropertyId(),
122 unique_id_variant, &result));
123 EXPECT_UIA_BSTR_EQ(result, UIA_NamePropertyId, L"root");
124 result.Reset();
125
126 // When |start_after_element| of FindItemByProperty() is "text1", there
127 // should be no element found, since "text1" comes after the element we are
128 // looking for.
129 EXPECT_HRESULT_SUCCEEDED(item_container_provider->FindItemByProperty(
130 text1_raw_element_provider_simple.Get(),
131 UiaRegistrarWin::GetInstance().GetUiaUniqueIdPropertyId(),
132 unique_id_variant, &result));
133 EXPECT_EQ(nullptr, result.Get());
134 result.Reset();
135
136 // When |start_after_element| of FindItemByProperty() is "button", there
137 // should be no element found, since "button" comes after the element we are
138 // looking for.
139 EXPECT_HRESULT_SUCCEEDED(item_container_provider->FindItemByProperty(
140 button_raw_element_provider_simple.Get(),
141 UiaRegistrarWin::GetInstance().GetUiaUniqueIdPropertyId(),
142 unique_id_variant, &result));
143 EXPECT_EQ(nullptr, result.Get());
144
145 result.Reset();
146 unique_id_variant.Release();
147 }
148
149 // Fetch the AxUniqueId of "text1", and verify if we can retrieve its
150 // corresponding IRawElementProviderSimple through FindItemByProperty().
151 {
152 unique_id = AXPlatformNodeFromNode(text1_node)->GetUniqueId();
153 unique_id_variant.Set(SysAllocString(reinterpret_cast<const wchar_t*>(
154 base::NumberToString16(-unique_id).c_str())));
155
156 // When |start_after_element| of FindItemByProperty() is nullptr, we should
157 // be able to find "text1".
158 EXPECT_HRESULT_SUCCEEDED(item_container_provider->FindItemByProperty(
159 nullptr, UiaRegistrarWin::GetInstance().GetUiaUniqueIdPropertyId(),
160 unique_id_variant, &result));
161 EXPECT_UIA_BSTR_EQ(result, UIA_NamePropertyId, L"text1");
162 result.Reset();
163
164 // When |start_after_element| of FindItemByProperty() is "text1", there
165 // should be no element found, since "text1" equals the element we are
166 // looking for.
167 EXPECT_HRESULT_SUCCEEDED(item_container_provider->FindItemByProperty(
168 text1_raw_element_provider_simple.Get(),
169 UiaRegistrarWin::GetInstance().GetUiaUniqueIdPropertyId(),
170 unique_id_variant, &result));
171 EXPECT_EQ(nullptr, result.Get());
172 result.Reset();
173
174 // When |start_after_element| of FindItemByProperty() is "button", there
175 // should be no element found, since "button" comes after the element we are
176 // looking for.
177 EXPECT_HRESULT_SUCCEEDED(item_container_provider->FindItemByProperty(
178 button_raw_element_provider_simple.Get(),
179 UiaRegistrarWin::GetInstance().GetUiaUniqueIdPropertyId(),
180 unique_id_variant, &result));
181 EXPECT_EQ(nullptr, result.Get());
182 result.Reset();
183 unique_id_variant.Release();
184 }
185
186 // Fetch the AxUniqueId of "button", and verify we can retrieve its
187 // corresponding IRawElementProviderSimple through FindItemByProperty().
188 {
189 unique_id = AXPlatformNodeFromNode(button_node)->GetUniqueId();
190 unique_id_variant.Set(SysAllocString(reinterpret_cast<const wchar_t*>(
191 base::NumberToString16(-unique_id).c_str())));
192
193 // When |start_after_element| of FindItemByProperty() is nullptr, we should
194 // be able to find "button".
195 EXPECT_HRESULT_SUCCEEDED(item_container_provider->FindItemByProperty(
196 nullptr, UiaRegistrarWin::GetInstance().GetUiaUniqueIdPropertyId(),
197 unique_id_variant, &result));
198 EXPECT_UIA_BSTR_EQ(result, UIA_NamePropertyId, L"button");
199 result.Reset();
200
201 // When |start_after_element| of FindItemByProperty() is "text1", we should
202 // be able to find "button".
203 EXPECT_HRESULT_SUCCEEDED(item_container_provider->FindItemByProperty(
204 text1_raw_element_provider_simple.Get(),
205 UiaRegistrarWin::GetInstance().GetUiaUniqueIdPropertyId(),
206 unique_id_variant, &result));
207 EXPECT_UIA_BSTR_EQ(result, UIA_NamePropertyId, L"button");
208 result.Reset();
209
210 // When |start_after_element| of FindItemByProperty() is "button", there
211 // should be no element found, since "button" equals the element we are
212 // looking for.
213 EXPECT_HRESULT_SUCCEEDED(item_container_provider->FindItemByProperty(
214 button_raw_element_provider_simple.Get(),
215 UiaRegistrarWin::GetInstance().GetUiaUniqueIdPropertyId(),
216 unique_id_variant, &result));
217 EXPECT_EQ(nullptr, result.Get());
218 result.Reset();
219 unique_id_variant.Release();
220 }
221
222 // Fetch the AxUniqueId of "text2", and verify we can retrieve its
223 // corresponding IRawElementProviderSimple through FindItemByProperty().
224 {
225 unique_id =
226 AXPlatformNodeFromNode(button_node->children()[0])->GetUniqueId();
227 unique_id_variant.Set(SysAllocString(reinterpret_cast<const wchar_t*>(
228 base::NumberToString16(-unique_id).c_str())));
229
230 // When |start_after_element| of FindItemByProperty() is nullptr, we should
231 // be able to find "text2".
232 EXPECT_HRESULT_SUCCEEDED(item_container_provider->FindItemByProperty(
233 nullptr, UiaRegistrarWin::GetInstance().GetUiaUniqueIdPropertyId(),
234 unique_id_variant, &result));
235 EXPECT_UIA_BSTR_EQ(result, UIA_NamePropertyId, L"text2");
236
237 // When |start_after_element| of FindItemByProperty() is root, we should
238 // be able to find "text2".
239 EXPECT_HRESULT_SUCCEEDED(item_container_provider->FindItemByProperty(
240 root_raw_element_provider_simple.Get(),
241 UiaRegistrarWin::GetInstance().GetUiaUniqueIdPropertyId(),
242 unique_id_variant, &result));
243 EXPECT_UIA_BSTR_EQ(result, UIA_NamePropertyId, L"text2");
244
245 // When |start_after_element| of FindItemByProperty() is "text1", we should
246 // be able to find "text2".
247 EXPECT_HRESULT_SUCCEEDED(item_container_provider->FindItemByProperty(
248 text1_raw_element_provider_simple.Get(),
249 UiaRegistrarWin::GetInstance().GetUiaUniqueIdPropertyId(),
250 unique_id_variant, &result));
251 EXPECT_UIA_BSTR_EQ(result, UIA_NamePropertyId, L"text2");
252
253 // When |start_after_element| of FindItemByProperty() is "button", we should
254 // be able to find "text2".
255 EXPECT_HRESULT_SUCCEEDED(item_container_provider->FindItemByProperty(
256 button_raw_element_provider_simple.Get(),
257 UiaRegistrarWin::GetInstance().GetUiaUniqueIdPropertyId(),
258 unique_id_variant, &result));
259 EXPECT_UIA_BSTR_EQ(result, UIA_NamePropertyId, L"text2");
260 }
261}
#define EXPECT_UIA_BSTR_EQ(node, property_id, expected)
void Set(const wchar_t *str)
std::u16string NumberToString16(float number)
Definition: string_utils.cc:75

◆ TEST_F() [12/325]

ui::TEST_F ( AXPlatformNodeMacTest  ,
AccessibilityRangeForPositionDoesntCrash   
)

Definition at line 51 of file ax_platform_node_mac_unittest.mm.

51 {
53 root.id = 1;
54 root.relative_bounds.bounds = gfx::RectF(0, 0, 40, 40);
55
56 Init(root);
57 AXNode* root_node = GetRootAsAXNode();
58 ASSERT_TRUE(root_node != nullptr);
59
60 AXPlatformNode* platform_node = AXPlatformNodeFromNode(root_node);
61 ASSERT_TRUE(platform_node != nullptr);
62
63 NSPoint point = NSMakePoint(0, 0);
64 AXPlatformNodeCocoa* native_root = platform_node->GetNativeViewAccessible();
65 ASSERT_TRUE(native_root != nullptr);
66
67 [native_root accessibilityRangeForPosition:(NSPoint)point];
68}
virtual gfx::NativeViewAccessible GetNativeViewAccessible()=0

◆ TEST_F() [13/325]

ui::TEST_F ( AXPlatformNodeMacTest  ,
CanGetCocoaPlatformNodeFromTree   
)

Definition at line 33 of file ax_platform_node_mac_unittest.mm.

33 {
35 root.id = 1;
36 root.relative_bounds.bounds = gfx::RectF(0, 0, 40, 40);
37
38 Init(root);
39 AXNode* root_node = GetRootAsAXNode();
40 ASSERT_TRUE(root_node != nullptr);
41
42 AXPlatformNode* platform_node = AXPlatformNodeFromNode(root_node);
43 ASSERT_TRUE(platform_node != nullptr);
44
45 AXPlatformNodeCocoa* native_root = platform_node->GetNativeViewAccessible();
46 EXPECT_TRUE(native_root != nullptr);
47}

◆ TEST_F() [14/325]

ui::TEST_F ( AXPlatformNodeTextProviderTest  ,
CreateDegenerateRangeFromStart   
)

Definition at line 66 of file ax_platform_node_textprovider_win_unittest.cc.

66 {
67 AXNodeData text1_data;
68 text1_data.id = 3;
70 text1_data.SetName("some text");
71
72 AXNodeData text2_data;
73 text2_data.id = 4;
75 text2_data.SetName("more text");
76
77 AXNodeData link_data;
78 link_data.id = 2;
79 link_data.role = ax::mojom::Role::kLink;
80 link_data.child_ids = {3, 4};
81
82 AXNodeData root_data;
83 root_data.id = 1;
84 root_data.role = ax::mojom::Role::kStaticText;
85 root_data.SetName("Document");
86 root_data.child_ids = {2};
87
89 AXTreeData tree_data;
90 tree_data.tree_id = AXTreeID::CreateNewAXTreeID();
91 update.tree_data = tree_data;
92 update.has_tree_data = true;
93 update.root_id = root_data.id;
94 update.nodes = {root_data, link_data, text1_data, text2_data};
95
96 Init(update);
97 AXNode* root_node = GetRootAsAXNode();
98 AXNode* link_node = root_node->children()[0];
99 AXNode* text2_node = link_node->children()[1];
100 AXPlatformNodeWin* owner =
101 static_cast<AXPlatformNodeWin*>(AXPlatformNodeFromNode(root_node));
102 BASE_DCHECK(owner);
103
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);
110
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)));
120
121 // Degenerate range created on root node should be:
122 // <>some textmore text
123 ComPtr<ITextRangeProvider> text_range_provider =
124 AXPlatformNodeTextProviderWin::CreateDegenerateRangeAtStart(
125 root_platform_node.Get());
126 SetOwner(owner, text_range_provider.Get());
127 base::win::ScopedBstr text_content;
128 EXPECT_HRESULT_SUCCEEDED(
129 text_range_provider->GetText(-1, text_content.Receive()));
130 EXPECT_EQ(0, wcscmp(text_content.Get(), L""));
131
132 ComPtr<AXPlatformNodeTextRangeProviderWin> actual_range;
133 text_range_provider->QueryInterface(IID_PPV_ARGS(&actual_range));
134 AXNodePosition::AXPositionInstance expected_start, expected_end;
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);
139 text_content.Release();
140
141 // Degenerate range created on link node should be:
142 // <>some textmore text
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);
153 text_content.Release();
154
155 // Degenerate range created on more text node should be:
156 // some text<>more text
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);
169 text_content.Release();
170}
BSTR Get() const
Definition: scoped_bstr.h:33
void SetName(const std::string &name)

◆ TEST_F() [15/325]

ui::TEST_F ( AXPlatformNodeTextProviderTest  ,
DISABLED_ITextProviderDocumentRangeTrailingIgnored   
)

Definition at line 448 of file ax_platform_node_textprovider_win_unittest.cc.

449 {
450 // ++1 root
451 // ++++2 kGenericContainer
452 // ++++++3 kStaticText "Hello"
453 // ++++4 kGenericContainer
454 // ++++++5 kGenericContainer
455 // ++++++++6 kStaticText "3.14"
456 // ++++7 kGenericContainer (ignored)
457 // ++++++8 kGenericContainer (ignored)
458 // ++++++++9 kStaticText "ignored"
459 AXNodeData root_1;
460 AXNodeData gc_2;
461 AXNodeData static_text_3;
462 AXNodeData gc_4;
463 AXNodeData gc_5;
464 AXNodeData static_text_6;
465 AXNodeData gc_7_ignored;
466 AXNodeData gc_8_ignored;
467 AXNodeData static_text_9_ignored;
468
469 root_1.id = 1;
470 gc_2.id = 2;
471 static_text_3.id = 3;
472 gc_4.id = 4;
473 gc_5.id = 5;
474 static_text_6.id = 6;
475 gc_7_ignored.id = 7;
476 gc_8_ignored.id = 8;
477 static_text_9_ignored.id = 9;
478
480 root_1.child_ids = {gc_2.id, gc_4.id, gc_7_ignored.id};
481 root_1.SetName("Document");
482
485 {static_text_3.id});
486 gc_2.child_ids = {static_text_3.id};
487
488 static_text_3.role = ax::mojom::Role::kStaticText;
489 static_text_3.SetName("Hello");
490
493 {gc_5.id});
494 gc_4.child_ids = {gc_5.id};
495
497 gc_5.child_ids = {static_text_6.id};
498
499 static_text_6.role = ax::mojom::Role::kStaticText;
500 static_text_6.SetName("3.14");
501
503 gc_7_ignored.child_ids = {gc_8_ignored.id};
505
507 gc_8_ignored.child_ids = {static_text_9_ignored.id};
509
510 static_text_9_ignored.role = ax::mojom::Role::kStaticText;
511 static_text_9_ignored.SetName("ignored");
512 static_text_9_ignored.AddState(ax::mojom::State::kIgnored);
513
515 AXTreeData tree_data;
516 tree_data.tree_id = AXTreeID::CreateNewAXTreeID();
517 update.tree_data = tree_data;
518 update.has_tree_data = true;
519 update.root_id = root_1.id;
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};
523
524 Init(update);
525
526 ComPtr<IRawElementProviderSimple> root_node =
527 GetRootIRawElementProviderSimple();
528
529 ComPtr<ITextProvider> text_provider;
530 EXPECT_HRESULT_SUCCEEDED(
531 root_node->GetPatternProvider(UIA_TextPatternId, &text_provider));
532
533 ComPtr<ITextRangeProvider> text_range_provider;
534 EXPECT_HRESULT_SUCCEEDED(
535 text_provider->get_DocumentRange(&text_range_provider));
536
537 ComPtr<AXPlatformNodeTextRangeProviderWin> text_range;
538 text_range_provider->QueryInterface(IID_PPV_ARGS(&text_range));
539
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());
546
547 AXNodePosition::AXPositionInstance expected_start =
548 owner->GetDelegate()->CreateTextPositionAt(0)->AsLeafTextPosition();
549 AXNodePosition::AXPositionInstance expected_end =
550 owner->GetDelegate()
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);
556}
void AddIntListAttribute(ax::mojom::IntListAttribute attribute, const std::vector< int32_t > &value)

◆ TEST_F() [16/325]

ui::TEST_F ( AXPlatformNodeTextProviderTest  ,
ITextProviderDocumentRange   
)

Definition at line 422 of file ax_platform_node_textprovider_win_unittest.cc.

422 {
423 AXNodeData text_data;
424 text_data.id = 2;
426 text_data.SetName("some text");
427
428 AXNodeData root_data;
429 root_data.id = 1;
431 root_data.SetName("Document");
432 root_data.child_ids.push_back(2);
433
434 Init(root_data, text_data);
435
436 ComPtr<IRawElementProviderSimple> root_node =
437 GetRootIRawElementProviderSimple();
438
439 ComPtr<ITextProvider> text_provider;
440 EXPECT_HRESULT_SUCCEEDED(
441 root_node->GetPatternProvider(UIA_TextPatternId, &text_provider));
442
443 ComPtr<ITextRangeProvider> text_range_provider;
444 EXPECT_HRESULT_SUCCEEDED(
445 text_provider->get_DocumentRange(&text_range_provider));
446}

◆ TEST_F() [17/325]

ui::TEST_F ( AXPlatformNodeTextProviderTest  ,
ITextProviderDocumentRangeNested   
)

Definition at line 558 of file ax_platform_node_textprovider_win_unittest.cc.

558 {
559 AXNodeData text_data;
560 text_data.id = 3;
562 text_data.SetName("some text");
563
564 AXNodeData paragraph_data;
565 paragraph_data.id = 2;
566 paragraph_data.role = ax::mojom::Role::kParagraph;
567 paragraph_data.child_ids.push_back(3);
568
569 AXNodeData root_data;
570 root_data.id = 1;
572 root_data.SetName("Document");
573 root_data.child_ids.push_back(2);
574
575 Init(root_data, paragraph_data, text_data);
576
577 ComPtr<IRawElementProviderSimple> root_node =
578 GetRootIRawElementProviderSimple();
579
580 ComPtr<ITextProvider> text_provider;
581 EXPECT_HRESULT_SUCCEEDED(
582 root_node->GetPatternProvider(UIA_TextPatternId, &text_provider));
583
584 ComPtr<ITextRangeProvider> text_range_provider;
585 EXPECT_HRESULT_SUCCEEDED(
586 text_provider->get_DocumentRange(&text_range_provider));
587}

◆ TEST_F() [18/325]

ui::TEST_F ( AXPlatformNodeTextProviderTest  ,
ITextProviderGetActiveComposition   
)

Definition at line 826 of file ax_platform_node_textprovider_win_unittest.cc.

826 {
827 AXNodeData text_data;
828 text_data.id = 2;
830 text_data.SetName("some text");
831
832 AXNodeData root_data;
833 root_data.id = 1;
835 root_data.SetName("Document");
836 root_data.child_ids.push_back(2);
837
839 AXTreeData tree_data;
840 tree_data.tree_id = AXTreeID::CreateNewAXTreeID();
841 update.tree_data = tree_data;
842 update.has_tree_data = true;
843 update.root_id = root_data.id;
844 update.nodes.push_back(root_data);
845 update.nodes.push_back(text_data);
846 Init(update);
847
848 ComPtr<IRawElementProviderSimple> root_node =
849 GetRootIRawElementProviderSimple();
850
851 ComPtr<ITextProvider> root_text_provider;
852 EXPECT_HRESULT_SUCCEEDED(
853 root_node->GetPatternProvider(UIA_TextPatternId, &root_text_provider));
854
855 ComPtr<ITextEditProvider> root_text_edit_provider;
856 EXPECT_HRESULT_SUCCEEDED(root_node->GetPatternProvider(
857 UIA_TextEditPatternId, &root_text_edit_provider));
858
859 ComPtr<ITextRangeProvider> text_range_provider;
860 root_text_edit_provider->GetActiveComposition(&text_range_provider);
861 ASSERT_EQ(nullptr, text_range_provider);
862
863 ComPtr<AXPlatformNodeTextProviderWin> root_platform_node;
864 root_text_provider->QueryInterface(IID_PPV_ARGS(&root_platform_node));
865
866 AXActionData action_data;
867 action_data.action = ax::mojom::Action::kFocus;
868 action_data.target_node_id = 1;
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);
873
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);
884}
std::unique_ptr< AXPosition< AXNodePosition, AXNode > > AXPositionInstance
Definition: ax_position.h:163
ax::mojom::Action action

◆ TEST_F() [19/325]

ui::TEST_F ( AXPlatformNodeTextProviderTest  ,
ITextProviderGetConversionTarget   
)

Definition at line 886 of file ax_platform_node_textprovider_win_unittest.cc.

886 {
887 AXNodeData text_data;
888 text_data.id = 2;
890 text_data.SetName("some text");
891
892 AXNodeData root_data;
893 root_data.id = 1;
895 root_data.SetName("Document");
896 root_data.child_ids.push_back(2);
897
899 AXTreeData tree_data;
900 tree_data.tree_id = AXTreeID::CreateNewAXTreeID();
901 update.tree_data = tree_data;
902 update.has_tree_data = true;
903 update.root_id = root_data.id;
904 update.nodes.push_back(root_data);
905 update.nodes.push_back(text_data);
906 Init(update);
907
908 ComPtr<IRawElementProviderSimple> root_node =
909 GetRootIRawElementProviderSimple();
910
911 ComPtr<ITextProvider> root_text_provider;
912 EXPECT_HRESULT_SUCCEEDED(
913 root_node->GetPatternProvider(UIA_TextPatternId, &root_text_provider));
914
915 ComPtr<ITextEditProvider> root_text_edit_provider;
916 EXPECT_HRESULT_SUCCEEDED(root_node->GetPatternProvider(
917 UIA_TextEditPatternId, &root_text_edit_provider));
918
919 ComPtr<ITextRangeProvider> text_range_provider;
920 root_text_edit_provider->GetConversionTarget(&text_range_provider);
921 ASSERT_EQ(nullptr, text_range_provider);
922
923 ComPtr<AXPlatformNodeTextProviderWin> root_platform_node;
924 root_text_provider->QueryInterface(IID_PPV_ARGS(&root_platform_node));
925
926 AXActionData action_data;
927 action_data.action = ax::mojom::Action::kFocus;
928 action_data.target_node_id = 1;
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);
933
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);
944}

◆ TEST_F() [20/325]

ui::TEST_F ( AXPlatformNodeTextProviderTest  ,
ITextProviderGetSelection   
)

Definition at line 616 of file ax_platform_node_textprovider_win_unittest.cc.

616 {
617 AXNodeData text_data;
618 text_data.id = 2;
620 text_data.SetName("some text");
621
622 AXNodeData textbox_data;
623 textbox_data.id = 3;
625 textbox_data.SetName("textbox text");
627
628 AXNodeData nonatomic_textfield_data;
629 nonatomic_textfield_data.id = 4;
630 nonatomic_textfield_data.role = ax::mojom::Role::kGroup;
631 nonatomic_textfield_data.child_ids = {5};
632
633 AXNodeData text_child_data;
634 text_child_data.id = 5;
635 text_child_data.role = ax::mojom::Role::kStaticText;
636 text_child_data.SetName("text");
637
638 AXNodeData root_data;
639 root_data.id = 1;
640 root_data.role = ax::mojom::Role::kStaticText;
641 root_data.SetName("Document");
642 root_data.child_ids = {2, 3, 4};
643
645 AXTreeData tree_data;
646 tree_data.tree_id = AXTreeID::CreateNewAXTreeID();
647 update.tree_data = tree_data;
648 update.has_tree_data = true;
649 update.root_id = root_data.id;
650 update.nodes = {root_data, text_data, textbox_data, nonatomic_textfield_data,
651 text_child_data};
652 Init(update);
653
654 ComPtr<IRawElementProviderSimple> root_node =
655 GetRootIRawElementProviderSimple();
656
657 ComPtr<ITextProvider> root_text_provider;
658 EXPECT_HRESULT_SUCCEEDED(
659 root_node->GetPatternProvider(UIA_TextPatternId, &root_text_provider));
660
662 root_text_provider->GetSelection(selections.Receive());
663 ASSERT_EQ(nullptr, selections.Get());
664
665 ComPtr<AXPlatformNodeTextProviderWin> root_platform_node;
666 root_text_provider->QueryInterface(IID_PPV_ARGS(&root_platform_node));
667
668 AXPlatformNodeWin* owner = GetOwner(root_platform_node.Get());
669 AXTreeData& selected_tree_data =
670 const_cast<AXTreeData&>(owner->GetDelegate()->GetTreeData());
671 selected_tree_data.sel_focus_object_id = 2;
672 selected_tree_data.sel_anchor_object_id = 2;
673 selected_tree_data.sel_anchor_offset = 0;
674 selected_tree_data.sel_focus_offset = 4;
675
676 root_text_provider->GetSelection(selections.Receive());
677 ASSERT_NE(nullptr, selections.Get());
678
679 LONG ubound;
680 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetUBound(selections.Get(), 1, &ubound));
681 EXPECT_EQ(0, ubound);
682 LONG lbound;
683 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetLBound(selections.Get(), 1, &lbound));
684 EXPECT_EQ(0, lbound);
685
686 LONG index = 0;
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());
691
692 base::win::ScopedBstr text_content;
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();
697 selections.Reset();
698 text_range_provider.Reset();
699
700 // Verify that start and end are appropriately swapped when sel_anchor_offset
701 // is greater than sel_focus_offset
702 selected_tree_data.sel_focus_object_id = 2;
703 selected_tree_data.sel_anchor_object_id = 2;
704 selected_tree_data.sel_anchor_offset = 4;
705 selected_tree_data.sel_focus_offset = 0;
706
707 root_text_provider->GetSelection(selections.Receive());
708 ASSERT_NE(nullptr, selections.Get());
709
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);
714
715 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetElement(
716 selections.Get(), &index, static_cast<void**>(&text_range_provider)));
717 SetOwner(owner, text_range_provider.Get());
718
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();
723 selections.Reset();
724 text_range_provider.Reset();
725
726 // Verify that text ranges at an insertion point returns a degenerate (empty)
727 // text range via textbox with sel_anchor_offset equal to sel_focus_offset
728 selected_tree_data.sel_focus_object_id = 3;
729 selected_tree_data.sel_anchor_object_id = 3;
730 selected_tree_data.sel_anchor_offset = 1;
731 selected_tree_data.sel_focus_offset = 1;
732
733 AXNode* text_edit_node = GetRootAsAXNode()->children()[1];
734
735 ComPtr<IRawElementProviderSimple> text_edit_com =
736 QueryInterfaceFromNode<IRawElementProviderSimple>(text_edit_node);
737
738 ComPtr<ITextProvider> text_edit_provider;
739 EXPECT_HRESULT_SUCCEEDED(text_edit_com->GetPatternProvider(
740 UIA_TextPatternId, &text_edit_provider));
741
742 selections.Reset();
743 EXPECT_HRESULT_SUCCEEDED(
744 text_edit_provider->GetSelection(selections.Receive()));
745 EXPECT_NE(nullptr, selections.Get());
746
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);
751
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(0U, text_content.Length());
760 text_content.Reset();
761 selections.Reset();
762 text_edit_range_provider.Reset();
763
764 // Verify selections that span multiple nodes
765 selected_tree_data.sel_focus_object_id = 2;
766 selected_tree_data.sel_focus_offset = 0;
767 selected_tree_data.sel_anchor_object_id = 3;
768 selected_tree_data.sel_anchor_offset = 12;
769
770 root_text_provider->GetSelection(selections.Receive());
771 ASSERT_NE(nullptr, selections.Get());
772
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);
777
778 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetElement(
779 selections.Get(), &index, static_cast<void**>(&text_range_provider)));
780
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();
786 selections.Reset();
787 text_range_provider.Reset();
788
789 // Verify SAFEARRAY value for degenerate selection.
790 selected_tree_data.sel_focus_object_id = 2;
791 selected_tree_data.sel_anchor_object_id = 2;
792 selected_tree_data.sel_anchor_offset = 1;
793 selected_tree_data.sel_focus_offset = 1;
794
795 root_text_provider->GetSelection(selections.Receive());
796 ASSERT_NE(nullptr, selections.Get());
797
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);
802
803 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetElement(
804 selections.Get(), &index, static_cast<void**>(&text_range_provider)));
805
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();
811 selections.Reset();
812 text_range_provider.Reset();
813
814 // Removed testing logic for non-atomic text fields as we do not have this
815 // role.
816
817 // Now delete the tree (which will delete the associated elements) and verify
818 // that UIA_E_ELEMENTNOTAVAILABLE is returned when calling GetSelection on
819 // a dead element
820 DestroyTree();
821
822 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
823 text_edit_provider->GetSelection(selections.Receive()));
824}
void Reset(BSTR bstr=nullptr)
Definition: scoped_bstr.cc:42
size_t Length() const
Definition: scoped_bstr.cc:83
void Reset(SAFEARRAY *safearray=nullptr)
long LONG
Definition: windows_types.h:23

◆ TEST_F() [21/325]

ui::TEST_F ( AXPlatformNodeTextProviderTest  ,
ITextProviderRangeFromChild   
)

Definition at line 172 of file ax_platform_node_textprovider_win_unittest.cc.

172 {
173 AXNodeData text_data;
174 text_data.id = 2;
176 text_data.SetName("some text");
177
178 AXNodeData empty_text_data;
179 empty_text_data.id = 3;
180 empty_text_data.role = ax::mojom::Role::kStaticText;
181
182 AXNodeData root_data;
183 root_data.id = 1;
185 root_data.SetName("Document");
186 root_data.child_ids.push_back(2);
187 root_data.child_ids.push_back(3);
188
190 AXTreeData tree_data;
191 tree_data.tree_id = AXTreeID::CreateNewAXTreeID();
192 update.tree_data = tree_data;
193 update.has_tree_data = true;
194 update.root_id = root_data.id;
195 update.nodes.push_back(root_data);
196 update.nodes.push_back(text_data);
197 update.nodes.push_back(empty_text_data);
198
199 Init(update);
200
201 AXNode* root_node = GetRootAsAXNode();
202 AXNode* text_node = root_node->children()[0];
203 AXNode* empty_text_node = root_node->children()[1];
204 AXPlatformNodeWin* owner =
205 static_cast<AXPlatformNodeWin*>(AXPlatformNodeFromNode(root_node));
206 BASE_DCHECK(owner);
207
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);
214
215 // Call RangeFromChild on the root with the text child passed in.
216 ComPtr<ITextProvider> text_provider;
217 EXPECT_HRESULT_SUCCEEDED(
218 root_node_raw->GetPatternProvider(UIA_TextPatternId, &text_provider));
219
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());
224
225 base::win::ScopedBstr text_content;
226 EXPECT_HRESULT_SUCCEEDED(
227 text_range_provider->GetText(-1, text_content.Receive()));
228 EXPECT_EQ(0, wcscmp(text_content.Get(), L"some text"));
229
230 // Now test that the reverse relation doesn't return a valid
231 // ITextRangeProvider, and instead returns E_INVALIDARG.
232 EXPECT_HRESULT_SUCCEEDED(
233 text_node_raw->GetPatternProvider(UIA_TextPatternId, &text_provider));
234
236 text_provider->RangeFromChild(root_node_raw.Get(), &text_range_provider));
237
238 // Now test that a child with no text returns a degenerate range.
239 EXPECT_HRESULT_SUCCEEDED(
240 root_node_raw->GetPatternProvider(UIA_TextPatternId, &text_provider));
241
242 EXPECT_HRESULT_SUCCEEDED(text_provider->RangeFromChild(
243 empty_text_node_raw.Get(), &text_range_provider));
244 SetOwner(owner, text_range_provider.Get());
245
246 base::win::ScopedBstr empty_text_content;
247 EXPECT_HRESULT_SUCCEEDED(
248 text_range_provider->GetText(-1, empty_text_content.Receive()));
249 EXPECT_EQ(0, wcscmp(empty_text_content.Get(), L""));
250
251 // Test that passing in an object from a different instance of
252 // IRawElementProviderSimple than that of the valid text provider
253 // returns UIA_E_INVALIDOPERATION.
254 ComPtr<IRawElementProviderSimple> other_root_node_raw;
255 MockIRawElementProviderSimple::CreateMockIRawElementProviderSimple(
256 &other_root_node_raw);
257
258 EXPECT_HRESULT_SUCCEEDED(
259 root_node_raw->GetPatternProvider(UIA_TextPatternId, &text_provider));
260
261 EXPECT_UIA_INVALIDOPERATION(text_provider->RangeFromChild(
262 other_root_node_raw.Get(), &text_range_provider));
263}
#define EXPECT_UIA_INVALIDOPERATION(expr)

◆ TEST_F() [22/325]

ui::TEST_F ( AXPlatformNodeTextProviderTest  ,
ITextProviderRangeFromChildMultipleChildren   
)

Definition at line 265 of file ax_platform_node_textprovider_win_unittest.cc.

266 {
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;
275
277 root.id = ROOT_ID;
279 root.SetName("Document");
280 root.child_ids = {DIALOG_ID};
281
282 AXNodeData dialog;
283 dialog.id = DIALOG_ID;
284 dialog.role = ax::mojom::Role::kDialog;
285 dialog.child_ids = {DIALOG_LABEL_ID, DIALOG_DESCRIPTION_ID, BUTTON_ID,
286 DIALOG_DETAIL_ID};
287
288 AXNodeData dialog_label;
289 dialog_label.id = DIALOG_LABEL_ID;
290 dialog_label.role = ax::mojom::Role::kStaticText;
291 dialog_label.SetName("Dialog label.");
292
293 AXNodeData dialog_description;
294 dialog_description.id = DIALOG_DESCRIPTION_ID;
295 dialog_description.role = ax::mojom::Role::kStaticText;
296 dialog_description.SetName("Dialog description.");
297
298 AXNodeData button;
299 button.id = BUTTON_ID;
300 button.role = ax::mojom::Role::kButton;
301 button.child_ids = {BUTTON_IMG_ID, BUTTON_TEXT_ID};
302
303 AXNodeData button_img;
304 button_img.id = BUTTON_IMG_ID;
305 button_img.role = ax::mojom::Role::kImage;
306
307 AXNodeData button_text;
308 button_text.id = BUTTON_TEXT_ID;
309 button_text.role = ax::mojom::Role::kStaticText;
310 button_text.SetName("ok.");
311
312 AXNodeData dialog_detail;
313 dialog_detail.id = DIALOG_DETAIL_ID;
314 dialog_detail.role = ax::mojom::Role::kStaticText;
315 dialog_detail.SetName("Some more detail about dialog.");
316
318 AXTreeData tree_data;
319 tree_data.tree_id = AXTreeID::CreateNewAXTreeID();
320 update.tree_data = tree_data;
321 update.has_tree_data = true;
322 update.root_id = ROOT_ID;
323 update.nodes = {root, dialog, dialog_label, dialog_description,
324 button, button_img, button_text, dialog_detail};
325
326 Init(update);
327
328 AXNode* root_node = GetRootAsAXNode();
329 AXNode* dialog_node = root_node->children()[0];
330 AXPlatformNodeWin* owner =
331 static_cast<AXPlatformNodeWin*>(AXPlatformNodeFromNode(root_node));
332 BASE_DCHECK(owner);
333
334 ComPtr<IRawElementProviderSimple> root_node_raw =
335 QueryInterfaceFromNode<IRawElementProviderSimple>(root_node);
336 ComPtr<IRawElementProviderSimple> dialog_node_raw =
337 QueryInterfaceFromNode<IRawElementProviderSimple>(dialog_node);
338
339 // Call RangeFromChild on the root with the dialog child passed in.
340 ComPtr<ITextProvider> text_provider;
341 EXPECT_HRESULT_SUCCEEDED(
342 root_node_raw->GetPatternProvider(UIA_TextPatternId, &text_provider));
343
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());
348
349 base::win::ScopedBstr text_content;
350 EXPECT_HRESULT_SUCCEEDED(
351 text_range_provider->GetText(-1, text_content.Receive()));
352 EXPECT_EQ(fml::WideStringToUtf16(text_content.Get()),
353 u"Dialog label.Dialog description." + kEmbeddedCharacterAsString +
354 u"ok.Some more detail " + u"about dialog.");
355
356 // Check the reverse relationship that GetEnclosingElement on the text range
357 // gives back the 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());
362}
std::u16string WideStringToUtf16(const std::wstring_view str)

◆ TEST_F() [23/325]

ui::TEST_F ( AXPlatformNodeTextProviderTest  ,
ITextProviderSupportedSelection   
)

Definition at line 589 of file ax_platform_node_textprovider_win_unittest.cc.

589 {
590 AXNodeData text_data;
591 text_data.id = 2;
593 text_data.SetName("some text");
594
595 AXNodeData root_data;
596 root_data.id = 1;
598 root_data.SetName("Document");
599 root_data.child_ids.push_back(2);
600
601 Init(root_data, text_data);
602
603 ComPtr<IRawElementProviderSimple> root_node =
604 GetRootIRawElementProviderSimple();
605
606 ComPtr<ITextProvider> text_provider;
607 EXPECT_HRESULT_SUCCEEDED(
608 root_node->GetPatternProvider(UIA_TextPatternId, &text_provider));
609
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);
614}

◆ TEST_F() [24/325]

ui::TEST_F ( AXPlatformNodeTextProviderTest  ,
NearestTextIndexToPoint   
)

Definition at line 364 of file ax_platform_node_textprovider_win_unittest.cc.

364 {
365 AXNodeData text_data;
366 text_data.id = 2;
368 text_data.SetName("text");
369 // spacing: "t-e-x---t-"
371 {2, 4, 8, 10});
372
373 AXNodeData root_data;
374 root_data.id = 1;
375 root_data.role = ax::mojom::Role::kRootWebArea;
376 root_data.relative_bounds.bounds = gfx::RectF(1, 1, 2, 2);
377 root_data.child_ids.push_back(2);
378
379 Init(root_data, text_data);
380
381 AXNode* root_node = GetRootAsAXNode();
382 AXNode* text_node = root_node->children()[0];
383
384 struct NearestTextIndexTestData {
385 AXNode* node;
386 struct point_offset_expected_index_pair {
387 int point_offset_x;
388 int expected_index;
389 };
390 std::vector<point_offset_expected_index_pair> test_data;
391 };
392 NearestTextIndexTestData nodes[] = {
393 {text_node,
394 {{0, 0}, {2, 0}, {3, 1}, {4, 1}, {5, 2}, {8, 2}, {9, 3}, {10, 3}}},
395 {root_node,
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()) {
399 continue;
400 }
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));
406 // get internal implementation to access helper for testing
407 ComPtr<AXPlatformNodeTextProviderWin> platform_text_provider;
408 EXPECT_HRESULT_SUCCEEDED(
409 text_provider->QueryInterface(IID_PPV_ARGS(&platform_text_provider)));
410
411 ComPtr<AXPlatformNodeWin> platform_node;
412 EXPECT_HRESULT_SUCCEEDED(
413 element_provider->QueryInterface(IID_PPV_ARGS(&platform_node)));
414
415 for (auto pair : data.test_data) {
416 EXPECT_EQ(pair.expected_index, platform_node->NearestTextIndexToPoint(
417 gfx::Point(pair.point_offset_x, 0)));
418 }
419 }
420}

◆ TEST_F() [25/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
CaretAtEndOfTextFieldReadOnly   
)

Definition at line 7242 of file ax_platform_node_textrangeprovider_win_unittest.cc.

7242 {
7243 // This test places a degenerate range at end of text field, and it should not
7244 // normalize to other positions, so we should expect the
7245 // 'UIA_IsReadOnlyAttributeId' attribute queried at this position to return
7246 // false.
7247 // ++1 kRootWebArea
7248 // ++++2 kTextField editable value="hello"
7249 // ++++++3 kGenericContainer editable isLineBreakingObject=true
7250 // ++++++++4 kStaticText editable name="hello"
7251 // ++++++++++5 kInlineTextBox editable name="hello"
7252 // ++++6 kStaticText name="abc"
7253 // ++++++7 kInlineTextBox name="abc"
7254 AXNodeData root_1;
7255 AXNodeData text_field_2;
7256 AXNodeData generic_container_3;
7257 AXNodeData static_text_4;
7258 AXNodeData inline_text_5;
7259 AXNodeData static_text_6;
7260 AXNodeData inline_text_7;
7261
7262 root_1.id = 1;
7263 text_field_2.id = 2;
7264 generic_container_3.id = 3;
7265 static_text_4.id = 4;
7266 inline_text_5.id = 5;
7267 static_text_6.id = 6;
7268 inline_text_7.id = 7;
7269
7271 root_1.child_ids = {text_field_2.id, static_text_6.id};
7272
7273 text_field_2.role = ax::mojom::Role::kTextField;
7275 text_field_2.SetValue("hello");
7276 text_field_2.child_ids = {generic_container_3.id};
7277
7278 generic_container_3.role = ax::mojom::Role::kGenericContainer;
7279 generic_container_3.AddState(ax::mojom::State::kEditable);
7280 generic_container_3.AddBoolAttribute(
7282 generic_container_3.child_ids = {static_text_4.id};
7283
7284 static_text_4.role = ax::mojom::Role::kStaticText;
7285 static_text_4.SetName("hello");
7287 static_text_4.child_ids = {inline_text_5.id};
7288
7289 inline_text_5.role = ax::mojom::Role::kInlineTextBox;
7290 inline_text_5.SetName("hello");
7292
7293 static_text_6.role = ax::mojom::Role::kStaticText;
7294 static_text_6.SetName("abc");
7295 static_text_6.child_ids = {inline_text_7.id};
7296
7297 inline_text_7.role = ax::mojom::Role::kInlineTextBox;
7298 inline_text_7.SetName("abc");
7299
7302 update.root_id = root_1.id;
7303 update.tree_data.tree_id = tree_id;
7304 update.has_tree_data = true;
7305 update.nodes = {root_1, text_field_2, generic_container_3,
7306 static_text_4, inline_text_5, static_text_6,
7307 inline_text_7};
7308
7309 Init(update);
7310 const AXTree* tree = GetTree();
7311 const AXNode* inline_text_5_node = tree->GetFromId(inline_text_5.id);
7312
7313 // Making |owner| AXID:1 so that |TestAXNodeWrapper::BuildAllWrappers|
7314 // will build the entire tree.
7315 AXPlatformNodeWin* owner = static_cast<AXPlatformNodeWin*>(
7316 AXPlatformNodeFromNode(GetNodeFromTree(tree_id, 1)));
7317
7318 ComPtr<AXPlatformNodeTextRangeProviderWin> range;
7319 base::win::ScopedVariant expected_variant;
7320
7321 CreateTextRangeProviderWin(
7322 range, owner,
7323 /*start_anchor*/ inline_text_5_node, /*start_offset*/ 3,
7324 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
7325 /*end_anchor*/ inline_text_5_node, /*end_offset*/ 4,
7326 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
7327
7328 EXPECT_UIA_TEXTRANGE_EQ(range, /*expected_text*/ L"l");
7329
7330 expected_variant.Set(false);
7331 EXPECT_UIA_TEXTATTRIBUTE_EQ(range, UIA_IsReadOnlyAttributeId,
7332 expected_variant);
7333
7334 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(range, TextPatternRangeEndpoint_Start,
7335 TextUnit_Character,
7336 /*count*/ 1,
7337 /*expected_text*/ L"",
7338 /*expected_count*/ 1);
7339 expected_variant.Set(false);
7340 EXPECT_UIA_TEXTATTRIBUTE_EQ(range, UIA_IsReadOnlyAttributeId,
7341 expected_variant);
7342
7343 EXPECT_UIA_MOVE(range, TextUnit_Character,
7344 /*count*/ 1,
7345 /*expected_text*/
7346 L"",
7347 /*expected_count*/ 1);
7348 expected_variant.Set(false);
7349 EXPECT_UIA_TEXTATTRIBUTE_EQ(range, UIA_IsReadOnlyAttributeId,
7350 expected_variant);
7351 const AXNodePosition::AXPositionInstance& start = GetStart(range.Get());
7352 const AXNodePosition::AXPositionInstance& end = GetEnd(range.Get());
7353 EXPECT_TRUE(start->AtEndOfAnchor());
7354 EXPECT_EQ(5, start->anchor_id());
7355 EXPECT_EQ(5, start->text_offset());
7356
7357 EXPECT_TRUE(end->AtEndOfAnchor());
7358 EXPECT_EQ(5, end->anchor_id());
7359 EXPECT_EQ(5, end->text_offset());
7360}
#define EXPECT_UIA_MOVE(text_range_provider, unit, count, expected_text, expected_count)
#define EXPECT_UIA_TEXTATTRIBUTE_EQ(provider, attribute, variant)
#define EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(text_range_provider, endpoint, unit, count, expected_text, expected_count)
#define EXPECT_UIA_TEXTRANGE_EQ(provider, expected_content)
void SetValue(const std::string &value)
void AddBoolAttribute(ax::mojom::BoolAttribute attribute, bool value)

◆ TEST_F() [26/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_GeneratedNewlineReturnsCommonAnchorReadonly   
)

Definition at line 7364 of file ax_platform_node_textrangeprovider_win_unittest.cc.

7365 {
7366 // This test places a range that starts at the end of a paragraph and
7367 // ends at the beginning of the next paragraph. The range only contains the
7368 // generated newline character. The readonly attribute value returned should
7369 // be the one of the common anchor of the start and end endpoint.
7370
7371 // ++1 kRootWebArea
7372 // ++++2 kGenericContainer
7373 // ++++++3 kImage
7374 // ++++++4 kTextField editable
7375 // ++++5 kGenericContainer editable
7376 // ++++++6 kImage
7377 // ++++++7 kTextField editable
7378 // ++++8 kGenericContainer
7379 // ++++++9 kTextField editable
7380 // ++++++10 kTextField editable
7381 AXNodeData root_1;
7382 AXNodeData generic_container_2;
7383 AXNodeData image_3;
7384 AXNodeData text_field_4;
7385 AXNodeData generic_container_5;
7386 AXNodeData image_6;
7387 AXNodeData text_field_7;
7388 AXNodeData generic_container_8;
7389 AXNodeData text_field_9;
7390 AXNodeData text_field_10;
7391
7392 root_1.id = 1;
7393 generic_container_2.id = 2;
7394 image_3.id = 3;
7395 text_field_4.id = 4;
7396 generic_container_5.id = 5;
7397 image_6.id = 6;
7398 text_field_7.id = 7;
7399 generic_container_8.id = 8;
7400 text_field_9.id = 9;
7401 text_field_10.id = 10;
7402
7404 root_1.child_ids = {generic_container_2.id, generic_container_5.id,
7405 generic_container_8.id};
7406
7407 generic_container_2.role = ax::mojom::Role::kGenericContainer;
7408 generic_container_2.child_ids = {image_3.id, text_field_4.id};
7409
7410 image_3.role = ax::mojom::Role::kImage;
7412 true);
7413
7414 text_field_4.role = ax::mojom::Role::kTextField;
7416
7417 generic_container_5.role = ax::mojom::Role::kGenericContainer;
7418 generic_container_5.AddState(ax::mojom::State::kEditable);
7419 generic_container_5.child_ids = {image_6.id, text_field_7.id};
7420
7421 image_6.role = ax::mojom::Role::kImage;
7423 true);
7424
7425 text_field_7.role = ax::mojom::Role::kTextField;
7427
7428 generic_container_8.role = ax::mojom::Role::kGenericContainer;
7429 generic_container_8.child_ids = {text_field_9.id, text_field_10.id};
7430
7431 text_field_9.role = ax::mojom::Role::kTextField;
7434 true);
7435
7436 text_field_10.role = ax::mojom::Role::kTextField;
7438
7441 update.root_id = root_1.id;
7442 update.tree_data.tree_id = tree_id;
7443 update.has_tree_data = true;
7444 update.nodes = {root_1, generic_container_2, image_3,
7445 text_field_4, generic_container_5, image_6,
7446 text_field_7, generic_container_8, text_field_9,
7447 text_field_10};
7448
7449 Init(update);
7450 const AXTree* tree = GetTree();
7451
7452 const AXNode* image_3_node = tree->GetFromId(image_3.id);
7453 const AXNode* image_6_node = tree->GetFromId(image_6.id);
7454 const AXNode* text_field_4_node = tree->GetFromId(text_field_4.id);
7455 const AXNode* text_field_7_node = tree->GetFromId(text_field_7.id);
7456 const AXNode* text_field_9_node = tree->GetFromId(text_field_9.id);
7457 const AXNode* text_field_10_node = tree->GetFromId(text_field_10.id);
7458
7459 // Making |owner| AXID:1 so that |TestAXNodeWrapper::BuildAllWrappers|
7460 // will build the entire tree.
7461 AXPlatformNodeWin* owner = static_cast<AXPlatformNodeWin*>(
7462 AXPlatformNodeFromNode(GetNodeFromTree(tree_id, 1)));
7463
7464 base::win::ScopedVariant expected_variant;
7465
7466 ComPtr<AXPlatformNodeTextRangeProviderWin> range_1;
7467 CreateTextRangeProviderWin(
7468 range_1, owner,
7469 /*start_anchor*/ image_3_node, /*start_offset*/ 1,
7470 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
7471 /*end_anchor*/ text_field_4_node, /*end_offset*/ 0,
7472 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
7473
7474 EXPECT_UIA_TEXTRANGE_EQ(range_1, /*expected_text*/ L"");
7475
7476 expected_variant.Set(true);
7477 EXPECT_UIA_TEXTATTRIBUTE_EQ(range_1, UIA_IsReadOnlyAttributeId,
7478 expected_variant);
7479 expected_variant.Reset();
7480
7481 ComPtr<AXPlatformNodeTextRangeProviderWin> range_2;
7482 CreateTextRangeProviderWin(
7483 range_2, owner,
7484 /*start_anchor*/ image_6_node, /*start_offset*/ 1,
7485 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
7486 /*end_anchor*/ text_field_7_node, /*end_offset*/ 0,
7487 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
7488
7489 EXPECT_UIA_TEXTRANGE_EQ(range_2, /*expected_text*/ L"");
7490
7491 expected_variant.Set(false);
7492 EXPECT_UIA_TEXTATTRIBUTE_EQ(range_2, UIA_IsReadOnlyAttributeId,
7493 expected_variant);
7494 expected_variant.Reset();
7495
7496 // This is testing a corner case when the range spans two text fields
7497 // separated by a paragraph boundary. This case used to not work because we
7498 // were relying on NormalizeTextRange to handle generated newlines and
7499 // normalization doesn't work when the range spans text fields.
7500 ComPtr<AXPlatformNodeTextRangeProviderWin> range_3;
7501 CreateTextRangeProviderWin(
7502 range_3, owner,
7503 /*start_anchor*/ text_field_9_node, /*start_offset*/ 1,
7504 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
7505 /*end_anchor*/ text_field_10_node, /*end_offset*/ 0,
7506 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
7507
7508 EXPECT_UIA_TEXTRANGE_EQ(range_3, /*expected_text*/ L"");
7509
7510 expected_variant.Set(true);
7511 EXPECT_UIA_TEXTATTRIBUTE_EQ(range_3, UIA_IsReadOnlyAttributeId,
7512 expected_variant);
7513 expected_variant.Reset();
7514}
void Reset(const VARIANT &var=kEmptyVariant)

◆ TEST_F() [27/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_MoveEndpointToLastIgnoredForTextNavigationNode   
)

Definition at line 7517 of file ax_platform_node_textrangeprovider_win_unittest.cc.

7518 {
7519 // This test moves the end endpoint of a range by one paragraph unit forward
7520 // to the last node of the tree. That last node happens to be a node that is
7521 // ignored for text navigation, but since it's the last node in the tree, it
7522 // should successfully move the endpoint to that node and keep the units_moved
7523 // value in sync.
7524 // ++1 kRootWebArea
7525 // ++++2 kStaticText name="abc"
7526 // ++++++3 kInlineTextBox name="abc"
7527 // ++++4 kGenericContainer
7528 AXNodeData root_1;
7529 AXNodeData static_text_2;
7530 AXNodeData inline_text_3;
7531 AXNodeData generic_container_4;
7532
7533 root_1.id = 1;
7534 static_text_2.id = 2;
7535 inline_text_3.id = 3;
7536 generic_container_4.id = 4;
7537
7539 root_1.child_ids = {static_text_2.id, generic_container_4.id};
7540
7541 static_text_2.role = ax::mojom::Role::kStaticText;
7542 static_text_2.SetName("abc");
7543 static_text_2.child_ids = {inline_text_3.id};
7544
7545 inline_text_3.role = ax::mojom::Role::kInlineTextBox;
7546 inline_text_3.SetName("abc");
7547
7548 generic_container_4.role = ax::mojom::Role::kGenericContainer;
7549
7552 update.root_id = root_1.id;
7553 update.tree_data.tree_id = tree_id;
7554 update.has_tree_data = true;
7555 update.nodes = {root_1, static_text_2, inline_text_3, generic_container_4};
7556
7557 Init(update);
7558 const AXTree* tree = GetTree();
7559 const AXNode* inline_text_3_node = tree->GetFromId(inline_text_3.id);
7560
7561 // Making |owner| AXID:1 so that |TestAXNodeWrapper::BuildAllWrappers|
7562 // will build the entire tree.
7563 AXPlatformNodeWin* owner = static_cast<AXPlatformNodeWin*>(
7564 AXPlatformNodeFromNode(GetNodeFromTree(tree_id, 1)));
7565
7566 ComPtr<AXPlatformNodeTextRangeProviderWin> range;
7567 base::win::ScopedVariant expected_variant;
7568
7569 CreateTextRangeProviderWin(
7570 range, owner,
7571 /*start_anchor*/ inline_text_3_node, /*start_offset*/ 0,
7572 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
7573 /*end_anchor*/ inline_text_3_node, /*end_offset*/ 3,
7574 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
7575
7576 EXPECT_UIA_TEXTRANGE_EQ(range, /*expected_text*/ L"abc");
7577
7578 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(range, TextPatternRangeEndpoint_End,
7579 TextUnit_Paragraph,
7580 /*count*/ 1,
7581 /*expected_text*/ L"abc\xFFFC",
7582 /*expected_count*/ 1);
7583}

◆ TEST_F() [28/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestDeleteSubtreeThatIncludesEndpointsNormalizeMoves   
)

Definition at line 6912 of file ax_platform_node_textrangeprovider_win_unittest.cc.

6913 {
6914 // This test updates the tree structure to ensure that the text range is still
6915 // valid after a subtree that includes the text range is deleted, resulting in
6916 // a change to the range that is adjusted forwards due to an ignored node.
6917 //
6918 // ++1 kRootWebArea
6919 // ++++2 kStaticText "one"
6920 // ++++3 kGenericContainer ignored
6921 // ++++++4 kGenericContainer
6922 // ++++++++5 kGenericContainer
6923 // ++++++++++6 kStaticText " two"
6924 // ++++++++7 kGenericContainer
6925 // ++++++++++8 kStaticText " three"
6926 // ++++++++9 kGenericContainer ignored
6927 // ++++++++++10 kStaticText " ignored" ignored
6928 // ++++11 kGenericContainer
6929 // ++++++12 kStaticText "four"
6930 AXNodeData root_1;
6931 AXNodeData text_2;
6932 AXNodeData gc_3;
6933 AXNodeData gc_4;
6934 AXNodeData gc_5;
6935 AXNodeData text_6;
6936 AXNodeData gc_7;
6937 AXNodeData text_8;
6938 AXNodeData gc_9;
6939 AXNodeData text_10;
6940 AXNodeData gc_11;
6941 AXNodeData text_12;
6942
6943 root_1.id = 1;
6944 text_2.id = 2;
6945 gc_3.id = 3;
6946 gc_4.id = 4;
6947 gc_5.id = 5;
6948 text_6.id = 6;
6949 gc_7.id = 7;
6950 text_8.id = 8;
6951 gc_9.id = 9;
6952 text_10.id = 10;
6953 gc_11.id = 11;
6954 text_12.id = 12;
6955
6957 root_1.child_ids = {text_2.id, gc_3.id, gc_11.id};
6958
6960 text_2.SetName("one");
6961
6964 gc_3.child_ids = {gc_4.id};
6965
6967 gc_4.child_ids = {gc_5.id, gc_7.id, gc_9.id};
6968
6970 gc_5.child_ids = {text_6.id};
6971
6973 text_6.SetName(" two");
6974
6976 gc_7.child_ids = {text_8.id};
6977
6979 text_8.SetName(" three");
6980
6983 gc_9.child_ids = {text_10.id};
6984
6987 text_10.SetName(" ignored");
6988
6990 gc_11.child_ids = {text_12.id};
6991
6993 text_12.SetName("four");
6994
6997 update.root_id = root_1.id;
6998 update.tree_data.tree_id = tree_id;
6999 update.has_tree_data = true;
7000 update.nodes = {root_1, text_2, gc_3, gc_4, gc_5, text_6,
7001 gc_7, text_8, gc_9, text_10, gc_11, text_12};
7002
7003 Init(update);
7004 const AXTree* tree = GetTree();
7005
7006 const AXNode* text_6_node = tree->GetFromId(text_6.id);
7007 const AXNode* text_8_node = tree->GetFromId(text_8.id);
7008
7009 // Making |owner| AXID:1 so that |TestAXNodeWrapper::BuildAllWrappers|
7010 // will build the entire tree.
7011 AXPlatformNodeWin* owner = static_cast<AXPlatformNodeWin*>(
7012 AXPlatformNodeFromNode(GetNodeFromTree(tree_id, 1)));
7013
7014 // Create a range that spans " two three" located on the leaf nodes.
7015
7016 // start: TextPosition, anchor_id=5, text_offset=0
7017 // end : TextPosition, anchor_id=7, text_offset=6
7018 ComPtr<AXPlatformNodeTextRangeProviderWin> range;
7019 CreateTextRangeProviderWin(
7020 range, owner,
7021 /*start_anchor*/ text_6_node, /*start_offset*/ 2,
7022 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
7023 /*end_anchor*/ text_8_node, /*end_offset*/ 6,
7024 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
7025
7026 EXPECT_UIA_TEXTRANGE_EQ(range, /*expected_text*/ L"wo three");
7027
7028 // Delete |gc_3|, which will delete the entire subtree where both of our
7029 // endpoints are.
7030 AXTreeUpdate test_update;
7031 gc_3.child_ids = {};
7032 test_update.nodes = {gc_3};
7033 ASSERT_TRUE(GetTree()->Unserialize(test_update));
7034
7035 // The text range should now be a degenerate range positioned at the end of
7036 // root, the parent of |gc_3|, since |gc_3| has been deleted.
7037 EXPECT_EQ(text_12.id, GetStart(range.Get())->anchor_id());
7038 EXPECT_EQ(0, GetStart(range.Get())->text_offset());
7039
7040 EXPECT_EQ(text_12.id, GetEnd(range.Get())->anchor_id());
7041 EXPECT_EQ(0, GetEnd(range.Get())->text_offset());
7042}

◆ TEST_F() [29/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestDeleteSubtreeWithIgnoredAncestors   
)

Definition at line 6781 of file ax_platform_node_textrangeprovider_win_unittest.cc.

6782 {
6783 // This test updates the tree structure to ensure that the text range doesn't
6784 // crash and points to null positions after a subtree that includes the text
6785 // range is deleted and all ancestors are ignored.
6786 //
6787 // ++1 kRootWebArea ignored
6788 // ++++2 kStaticText "one"
6789 // ++++3 kGenericContainer ignored
6790 // ++++++4 kGenericContainer
6791 // ++++++++5 kGenericContainer
6792 // ++++++++++6 kStaticText " two"
6793 // ++++++++7 kGenericContainer ignored
6794 // ++++++++++8 kStaticText " ignored" ignored
6795 // ++++++++9 kGenericContainer
6796 // ++++++++++10 kStaticText " three"
6797 // ++++11 kGenericContainer
6798 // ++++++12 kStaticText "four"
6799 AXNodeData root_1;
6800 AXNodeData text_2;
6801 AXNodeData gc_3;
6802 AXNodeData gc_4;
6803 AXNodeData gc_5;
6804 AXNodeData text_6;
6805 AXNodeData gc_7;
6806 AXNodeData text_8;
6807 AXNodeData gc_9;
6808 AXNodeData text_10;
6809 AXNodeData gc_11;
6810 AXNodeData text_12;
6811
6812 root_1.id = 1;
6813 text_2.id = 2;
6814 gc_3.id = 3;
6815 gc_4.id = 4;
6816 gc_5.id = 5;
6817 text_6.id = 6;
6818 gc_7.id = 7;
6819 text_8.id = 8;
6820 gc_9.id = 9;
6821 text_10.id = 10;
6822 gc_11.id = 11;
6823 text_12.id = 12;
6824
6826 root_1.child_ids = {text_2.id, gc_3.id, gc_11.id};
6828
6830 text_2.SetName("one");
6831
6834 gc_3.child_ids = {gc_4.id};
6835
6837 gc_4.child_ids = {gc_5.id, gc_7.id, gc_9.id};
6838
6840 gc_5.child_ids = {text_6.id};
6841
6843 text_6.SetName(" two");
6844
6847 gc_7.child_ids = {text_8.id};
6848
6851 text_8.SetName(" ignored");
6852
6854 gc_9.child_ids = {text_10.id};
6855
6857 text_10.SetName(" three");
6858
6860 gc_11.child_ids = {text_12.id};
6861
6863 text_12.SetName("four");
6864
6867 update.root_id = root_1.id;
6868 update.tree_data.tree_id = tree_id;
6869 update.has_tree_data = true;
6870 update.nodes = {root_1, text_2, gc_3, gc_4, gc_5, text_6,
6871 gc_7, text_8, gc_9, text_10, gc_11, text_12};
6872
6873 Init(update);
6874 const AXTree* tree = GetTree();
6875
6876 const AXNode* text_6_node = tree->GetFromId(text_6.id);
6877 const AXNode* text_10_node = tree->GetFromId(text_10.id);
6878
6879 // Making |owner| AXID:1 so that |TestAXNodeWrapper::BuildAllWrappers|
6880 // will build the entire tree.
6881 AXPlatformNodeWin* owner = static_cast<AXPlatformNodeWin*>(
6882 AXPlatformNodeFromNode(GetNodeFromTree(tree_id, 1)));
6883
6884 // Create a range that spans " two three" located on the leaf nodes.
6885
6886 // start: TextPosition, anchor_id=5, text_offset=0
6887 // end : TextPosition, anchor_id=7, text_offset=6
6888 ComPtr<AXPlatformNodeTextRangeProviderWin> range;
6889 CreateTextRangeProviderWin(
6890 range, owner,
6891 /*start_anchor*/ text_6_node, /*start_offset*/ 2,
6892 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
6893 /*end_anchor*/ text_10_node, /*end_offset*/ 6,
6894 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
6895
6896 EXPECT_UIA_TEXTRANGE_EQ(range, /*expected_text*/ L"wo three");
6897
6898 // Delete |gc_3|, which will delete the entire subtree where both of our
6899 // endpoints are.
6900 AXTreeUpdate test_update;
6901 gc_3.child_ids = {};
6902 test_update.nodes = {gc_3};
6903 ASSERT_TRUE(GetTree()->Unserialize(test_update));
6904
6905 // There was no unignored position in which to place the start and end - they
6906 // should now be null positions.
6907 EXPECT_TRUE(GetStart(range.Get())->IsNullPosition());
6908 EXPECT_TRUE(GetEnd(range.Get())->IsNullPosition());
6909}

◆ TEST_F() [30/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestITextRangeProviderExpandToEnclosingFormat   
)

Definition at line 1336 of file ax_platform_node_textrangeprovider_win_unittest.cc.

1337 {
1338 Init(BuildAXTreeForMoveByFormat());
1339 AXNode* root_node = GetRootAsAXNode();
1340 ComPtr<ITextRangeProvider> text_range_provider;
1341 GetTextRangeProviderFromTextNode(text_range_provider, root_node);
1342 ComPtr<AXPlatformNodeTextRangeProviderWin> text_range_provider_internal;
1343 ASSERT_HRESULT_SUCCEEDED(text_range_provider->QueryInterface(
1344 IID_PPV_ARGS(&text_range_provider_internal)));
1345
1347 text_range_provider,
1348 L"Text with formatting\nStandalone line with no formatting\nbold "
1349 L"text\nParagraph 1\nParagraph 2\nParagraph 3\nParagraph 4");
1350
1351 // https://docs.microsoft.com/en-us/windows/win32/api/uiautomationclient/nf-uiautomationclient-iuiautomationtextrange-expandtoenclosingunit
1352 // Consider two consecutive text units A and B.
1353 // The documentation illustrates 9 cases, but cases 1 and 9 are equivalent.
1354 // In each case, the expected output is a range from start of A to end of A.
1355
1356 // Create a range encompassing nodes 11-15 which will serve as text units A
1357 // and B for this test.
1358 ComPtr<ITextRangeProvider> units_a_b_provider;
1359 ASSERT_HRESULT_SUCCEEDED(text_range_provider->Clone(&units_a_b_provider));
1360 CopyOwnerToClone(text_range_provider.Get(), units_a_b_provider.Get());
1361
1362 int count;
1363 ASSERT_HRESULT_SUCCEEDED(units_a_b_provider->MoveEndpointByUnit(
1364 TextPatternRangeEndpoint_Start, TextUnit_Line, /*count*/ 5, &count));
1365 ASSERT_EQ(5, count);
1366 ASSERT_HRESULT_SUCCEEDED(units_a_b_provider->MoveEndpointByUnit(
1367 TextPatternRangeEndpoint_End, TextUnit_Line, /*count*/ -1, &count));
1368 ASSERT_EQ(-1, count);
1369 EXPECT_UIA_TEXTRANGE_EQ(units_a_b_provider,
1370 L"Paragraph 1\nParagraph 2\nParagraph 3");
1371
1372 // Create a range encompassing node 11 which will serve as our expected
1373 // value of a range from start of A to end of A.
1374 ComPtr<ITextRangeProvider> unit_a_provider;
1375 ASSERT_HRESULT_SUCCEEDED(units_a_b_provider->Clone(&unit_a_provider));
1376 CopyOwnerToClone(units_a_b_provider.Get(), unit_a_provider.Get());
1377 ASSERT_HRESULT_SUCCEEDED(unit_a_provider->MoveEndpointByUnit(
1378 TextPatternRangeEndpoint_End, TextUnit_Line, /*count*/ -2, &count));
1379 ASSERT_EQ(-2, count);
1380 EXPECT_UIA_TEXTRANGE_EQ(unit_a_provider, L"Paragraph 1");
1381
1382 // Case 1: Degenerate range at start of A.
1383 {
1384 SCOPED_TRACE("Case 1: Degenerate range at start of A.");
1385 ComPtr<ITextRangeProvider> test_case_provider;
1386 ASSERT_HRESULT_SUCCEEDED(unit_a_provider->Clone(&test_case_provider));
1387 CopyOwnerToClone(unit_a_provider.Get(), test_case_provider.Get());
1388 ASSERT_HRESULT_SUCCEEDED(test_case_provider->MoveEndpointByRange(
1389 TextPatternRangeEndpoint_End, test_case_provider.Get(),
1390 TextPatternRangeEndpoint_Start));
1391 EXPECT_UIA_TEXTRANGE_EQ(test_case_provider, L"");
1392
1393 ASSERT_HRESULT_SUCCEEDED(
1394 test_case_provider->ExpandToEnclosingUnit(TextUnit_Format));
1395 BOOL are_same;
1396 ASSERT_HRESULT_SUCCEEDED(
1397 test_case_provider->Compare(unit_a_provider.Get(), &are_same));
1398 EXPECT_TRUE(are_same);
1399 }
1400
1401 // Case 2: Range from start of A to middle of A.
1402 {
1403 SCOPED_TRACE("Case 2: Range from start of A to middle of A.");
1404 ComPtr<ITextRangeProvider> test_case_provider;
1405 ASSERT_HRESULT_SUCCEEDED(unit_a_provider->Clone(&test_case_provider));
1406 CopyOwnerToClone(unit_a_provider.Get(), test_case_provider.Get());
1407 ASSERT_HRESULT_SUCCEEDED(test_case_provider->MoveEndpointByUnit(
1408 TextPatternRangeEndpoint_End, TextUnit_Character, /*count*/ -7,
1409 &count));
1410 ASSERT_EQ(-7, count);
1411 EXPECT_UIA_TEXTRANGE_EQ(test_case_provider, L"Para");
1412
1413 ASSERT_HRESULT_SUCCEEDED(
1414 test_case_provider->ExpandToEnclosingUnit(TextUnit_Format));
1415 BOOL are_same;
1416 ASSERT_HRESULT_SUCCEEDED(
1417 test_case_provider->Compare(unit_a_provider.Get(), &are_same));
1418 EXPECT_TRUE(are_same);
1419 }
1420
1421 // Case 3: Range from start of A to end of A.
1422 {
1423 SCOPED_TRACE("Case 3: Range from start of A to end of A.");
1424 ComPtr<ITextRangeProvider> test_case_provider;
1425 ASSERT_HRESULT_SUCCEEDED(unit_a_provider->Clone(&test_case_provider));
1426 CopyOwnerToClone(unit_a_provider.Get(), test_case_provider.Get());
1427 EXPECT_UIA_TEXTRANGE_EQ(test_case_provider, L"Paragraph 1");
1428
1429 ASSERT_HRESULT_SUCCEEDED(
1430 test_case_provider->ExpandToEnclosingUnit(TextUnit_Format));
1431 BOOL are_same;
1432 ASSERT_HRESULT_SUCCEEDED(
1433 test_case_provider->Compare(unit_a_provider.Get(), &are_same));
1434 EXPECT_TRUE(are_same);
1435 }
1436
1437 // Case 4: Range from start of A to middle of B.
1438 {
1439 SCOPED_TRACE("Case 4: Range from start of A to middle of B.");
1440 ComPtr<ITextRangeProvider> test_case_provider;
1441 ASSERT_HRESULT_SUCCEEDED(unit_a_provider->Clone(&test_case_provider));
1442 CopyOwnerToClone(unit_a_provider.Get(), test_case_provider.Get());
1443 ASSERT_HRESULT_SUCCEEDED(test_case_provider->MoveEndpointByUnit(
1444 TextPatternRangeEndpoint_End, TextUnit_Character, /*count*/ 5, &count));
1445 ASSERT_EQ(5, count);
1446 EXPECT_UIA_TEXTRANGE_EQ(test_case_provider, L"Paragraph 1\nPara");
1447
1448 ASSERT_HRESULT_SUCCEEDED(
1449 test_case_provider->ExpandToEnclosingUnit(TextUnit_Format));
1450 BOOL are_same;
1451 ASSERT_HRESULT_SUCCEEDED(
1452 test_case_provider->Compare(unit_a_provider.Get(), &are_same));
1453 EXPECT_TRUE(are_same);
1454 }
1455
1456 // Case 5: Degenerate range in middle of A.
1457 {
1458 SCOPED_TRACE("Case 5: Degenerate range in middle of A.");
1459 ComPtr<ITextRangeProvider> test_case_provider;
1460 ASSERT_HRESULT_SUCCEEDED(unit_a_provider->Clone(&test_case_provider));
1461 CopyOwnerToClone(unit_a_provider.Get(), test_case_provider.Get());
1462 ASSERT_HRESULT_SUCCEEDED(test_case_provider->MoveEndpointByUnit(
1463 TextPatternRangeEndpoint_Start, TextUnit_Character, /*count*/ 4,
1464 &count));
1465 ASSERT_EQ(4, count);
1466 ASSERT_HRESULT_SUCCEEDED(test_case_provider->MoveEndpointByRange(
1467 TextPatternRangeEndpoint_End, test_case_provider.Get(),
1468 TextPatternRangeEndpoint_Start));
1469 EXPECT_UIA_TEXTRANGE_EQ(test_case_provider, L"");
1470
1471 ASSERT_HRESULT_SUCCEEDED(
1472 test_case_provider->ExpandToEnclosingUnit(TextUnit_Format));
1473 BOOL are_same;
1474 ASSERT_HRESULT_SUCCEEDED(
1475 test_case_provider->Compare(unit_a_provider.Get(), &are_same));
1476 EXPECT_TRUE(are_same);
1477 }
1478
1479 // Case 6: Range from middle of A to middle of A.
1480 {
1481 SCOPED_TRACE("Case 6: Range from middle of A to middle of A.");
1482 ComPtr<ITextRangeProvider> test_case_provider;
1483 ASSERT_HRESULT_SUCCEEDED(unit_a_provider->Clone(&test_case_provider));
1484 CopyOwnerToClone(unit_a_provider.Get(), test_case_provider.Get());
1485 ASSERT_HRESULT_SUCCEEDED(test_case_provider->MoveEndpointByUnit(
1486 TextPatternRangeEndpoint_Start, TextUnit_Character, /*count*/ 4,
1487 &count));
1488 ASSERT_EQ(4, count);
1489 ASSERT_HRESULT_SUCCEEDED(test_case_provider->MoveEndpointByUnit(
1490 TextPatternRangeEndpoint_End, TextUnit_Character, /*count*/ -2,
1491 &count));
1492 ASSERT_EQ(-2, count);
1493 EXPECT_UIA_TEXTRANGE_EQ(test_case_provider, L"graph");
1494
1495 ASSERT_HRESULT_SUCCEEDED(
1496 test_case_provider->ExpandToEnclosingUnit(TextUnit_Format));
1497 BOOL are_same;
1498 ASSERT_HRESULT_SUCCEEDED(
1499 test_case_provider->Compare(unit_a_provider.Get(), &are_same));
1500 EXPECT_TRUE(are_same);
1501 }
1502
1503 // Case 7: Range from middle of A to end of A.
1504 {
1505 SCOPED_TRACE("Case 7: Range from middle of A to end of A.");
1506 ComPtr<ITextRangeProvider> test_case_provider;
1507 ASSERT_HRESULT_SUCCEEDED(unit_a_provider->Clone(&test_case_provider));
1508 CopyOwnerToClone(unit_a_provider.Get(), test_case_provider.Get());
1509 ASSERT_HRESULT_SUCCEEDED(test_case_provider->MoveEndpointByUnit(
1510 TextPatternRangeEndpoint_Start, TextUnit_Character, /*count*/ 4,
1511 &count));
1512 ASSERT_EQ(4, count);
1513 EXPECT_UIA_TEXTRANGE_EQ(test_case_provider, L"graph 1");
1514
1515 ASSERT_HRESULT_SUCCEEDED(
1516 test_case_provider->ExpandToEnclosingUnit(TextUnit_Format));
1517 BOOL are_same;
1518 ASSERT_HRESULT_SUCCEEDED(
1519 test_case_provider->Compare(unit_a_provider.Get(), &are_same));
1520 EXPECT_TRUE(are_same);
1521 }
1522
1523 // Case 8: Range from middle of A to middle of B.
1524 {
1525 SCOPED_TRACE("Case 8: Range from middle of A to middle of B.");
1526 ComPtr<ITextRangeProvider> test_case_provider;
1527 ASSERT_HRESULT_SUCCEEDED(unit_a_provider->Clone(&test_case_provider));
1528 CopyOwnerToClone(unit_a_provider.Get(), test_case_provider.Get());
1529 ASSERT_HRESULT_SUCCEEDED(test_case_provider->MoveEndpointByUnit(
1530 TextPatternRangeEndpoint_Start, TextUnit_Character, /*count*/ 5,
1531 &count));
1532 ASSERT_EQ(5, count);
1533 ASSERT_HRESULT_SUCCEEDED(test_case_provider->MoveEndpointByUnit(
1534 TextPatternRangeEndpoint_End, TextUnit_Character, /*count*/ 5, &count));
1535 ASSERT_EQ(5, count);
1536 EXPECT_UIA_TEXTRANGE_EQ(test_case_provider, L"raph 1\nPara");
1537
1538 ASSERT_HRESULT_SUCCEEDED(
1539 test_case_provider->ExpandToEnclosingUnit(TextUnit_Format));
1540 BOOL are_same;
1541 ASSERT_HRESULT_SUCCEEDED(
1542 test_case_provider->Compare(unit_a_provider.Get(), &are_same));
1543 EXPECT_TRUE(are_same);
1544 }
1545}
int count
Definition: FontMgrTest.cpp:50
int BOOL
Definition: windows_types.h:37

◆ TEST_F() [31/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestITextRangeProviderExpandToEnclosingFormatWithEmptyObjects   
)

Definition at line 1548 of file ax_platform_node_textrangeprovider_win_unittest.cc.

1549 {
1550 // This test updates the tree structure to test a specific edge case.
1551 //
1552 // When using heading navigation, the empty objects (see
1553 // AXPosition::IsEmptyObjectReplacedByCharacter for information about empty
1554 // objects) sometimes cause a problem with
1555 // AXPlatformNodeTextRangeProviderWin::ExpandToEnclosingUnit.
1556 // With some specific AXTree (like the one used below), the empty object
1557 // causes ExpandToEnclosingUnit to move the range back on the heading that it
1558 // previously was instead of moving it forward/backward to the next heading.
1559 // To avoid this, empty objects are always marked as format boundaries.
1560 //
1561 // The issue normally occurs when a heading is directly followed by an ignored
1562 // empty object, itself followed by an unignored empty object.
1563 //
1564 // ++1 kRootWebArea
1565 // ++++2 kHeading
1566 // ++++++3 kStaticText
1567 // ++++++++4 kInlineTextBox
1568 // ++++5 kGenericContainer ignored
1569 // ++++6 kButton
1570 ui::AXNodeData root_1;
1571 ui::AXNodeData heading_2;
1572 ui::AXNodeData static_text_3;
1573 ui::AXNodeData inline_box_4;
1574 ui::AXNodeData generic_container_5;
1575 ui::AXNodeData button_6;
1576
1577 root_1.id = 1;
1578 heading_2.id = 2;
1579 static_text_3.id = 3;
1580 inline_box_4.id = 4;
1581 generic_container_5.id = 5;
1582 button_6.id = 6;
1583
1585 root_1.child_ids = {heading_2.id, generic_container_5.id, button_6.id};
1586
1587 heading_2.role = ax::mojom::Role::kHeading;
1588 heading_2.child_ids = {static_text_3.id};
1589
1590 static_text_3.role = ax::mojom::Role::kStaticText;
1591 static_text_3.child_ids = {inline_box_4.id};
1592 static_text_3.SetName("3.14");
1593
1595 inline_box_4.SetName("3.14");
1596
1597 generic_container_5.role = ax::mojom::Role::kGenericContainer;
1598 generic_container_5.AddBoolAttribute(
1600 generic_container_5.AddState(ax::mojom::State::kIgnored);
1601
1602 button_6.role = ax::mojom::Role::kButton;
1603
1605 ui::AXTreeData tree_data;
1607 update.tree_data = tree_data;
1608 update.has_tree_data = true;
1609 update.root_id = root_1.id;
1610 update.nodes.push_back(root_1);
1611 update.nodes.push_back(heading_2);
1612 update.nodes.push_back(static_text_3);
1613 update.nodes.push_back(inline_box_4);
1614 update.nodes.push_back(generic_container_5);
1615 update.nodes.push_back(button_6);
1616
1617 Init(update);
1618
1619 AXNode* root_node = GetRootAsAXNode();
1620 ComPtr<ITextRangeProvider> text_range_provider;
1621 GetTextRangeProviderFromTextNode(text_range_provider, root_node);
1622
1623 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"3.14\xFFFC");
1624
1625 // Create a degenerate range positioned at the boundary between nodes 4 and 6,
1626 // e.g., "3.14<>" and "<\xFFFC>" (because node 5 is ignored).
1627 int count;
1628 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1629 TextPatternRangeEndpoint_Start, TextUnit_Character, /*count*/ 5, &count));
1630 ASSERT_EQ(5, count);
1631 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1632 TextPatternRangeEndpoint_End, TextUnit_Character, /*count*/ -1, &count));
1633 ASSERT_EQ(-1, count);
1634 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"");
1635
1636 // ExpandToEnclosingUnit should move the range to the next non-ignored empty
1637 // object (i.e, node 6), and not at the beginning of node 4.
1638 ASSERT_HRESULT_SUCCEEDED(
1639 text_range_provider->ExpandToEnclosingUnit(TextUnit_Format));
1640 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"\xFFFC");
1641}

◆ TEST_F() [32/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestITextRangeProviderExpandToEnclosingParagraph   
)

Definition at line 1271 of file ax_platform_node_textrangeprovider_win_unittest.cc.

1272 {
1273 Init(BuildAXTreeForMove());
1274 AXNode* root_node = GetRootAsAXNode();
1275
1276 ComPtr<ITextRangeProvider> text_range_provider;
1277 GetTextRangeProviderFromTextNode(text_range_provider, root_node);
1278
1279 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider,
1280 /*expected_text*/ tree_for_move_full_text.data());
1281
1282 // Start endpoint is already on a paragraph's start boundary.
1283 //
1284 // Note that there are 5 paragraphs, not 6, because the line break element
1285 // between the first and second paragraph is merged in the text of the first
1286 // paragraph. This is standard UIA behavior which merges any trailing
1287 // whitespace with the previous paragraph.
1288 int count;
1289 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1290 TextPatternRangeEndpoint_End, TextUnit_Paragraph, /*count*/ -5, &count));
1291 EXPECT_EQ(-5, count);
1292 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"");
1293
1294 ASSERT_HRESULT_SUCCEEDED(
1295 text_range_provider->ExpandToEnclosingUnit(TextUnit_Paragraph));
1296 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"First line of text\n");
1297
1298 // Moving the start by two lines will create a degenerate range positioned
1299 // at the next paragraph (skipping the newline).
1300 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1301 TextPatternRangeEndpoint_Start, TextUnit_Line, /*count*/ 2, &count));
1302 EXPECT_EQ(2, count);
1303 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"");
1304
1305 ASSERT_HRESULT_SUCCEEDED(
1306 text_range_provider->ExpandToEnclosingUnit(TextUnit_Paragraph));
1307 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"Standalone line\n");
1308
1309 // Move to the next paragraph via MoveEndpointByUnit (line), then move to
1310 // the middle of the paragraph via Move (word), then expand by paragraph.
1311 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1312 TextPatternRangeEndpoint_Start, TextUnit_Line, /*count*/ 1, &count));
1313 EXPECT_EQ(1, count);
1314 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"");
1315 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Word,
1316 /*count*/ 1,
1317 /*expected_text*/
1318 L"",
1319 /*expected_count*/ 1);
1320 ASSERT_HRESULT_SUCCEEDED(
1321 text_range_provider->ExpandToEnclosingUnit(TextUnit_Paragraph));
1322 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"bold text\n");
1323
1324 // Create a degenerate range at the end of the document, then expand by
1325 // paragraph.
1326 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1327 TextPatternRangeEndpoint_Start, TextUnit_Document, /*count*/ 1, &count));
1328 EXPECT_EQ(1, count);
1329 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"");
1330 ASSERT_HRESULT_SUCCEEDED(
1331 text_range_provider->ExpandToEnclosingUnit(TextUnit_Paragraph));
1332 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"Paragraph 2");
1333}

◆ TEST_F() [33/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestITextRangeProviderGetAttributeValue   
)

Definition at line 3799 of file ax_platform_node_textrangeprovider_win_unittest.cc.

3800 {
3801 ui::AXNodeData text_data;
3802 text_data.id = 2;
3809 2);
3812 0xFFADBEEFU);
3813 text_data.AddIntAttribute(ax::mojom::IntAttribute::kColor, 0xFFADC0DEU);
3824 {0, 5, 0, 14, 19});
3826 {9, 9, 4, 18, 24});
3827 text_data.SetName("some text and some other text");
3828
3829 ui::AXNodeData heading_data;
3830 heading_data.id = 3;
3831 heading_data.role = ax::mojom::Role::kHeading;
3834 0xFFADBEEFU);
3835 heading_data.AddIntAttribute(ax::mojom::IntAttribute::kColor, 0xFFADC0DEU);
3839 heading_data.child_ids = {4};
3840
3841 ui::AXNodeData heading_text_data;
3842 heading_text_data.id = 4;
3843 heading_text_data.role = ax::mojom::Role::kStaticText;
3844 heading_text_data.AddState(ax::mojom::State::kInvisible);
3846 0xFFADBEEFU);
3848 0xFFADC0DEU);
3851 heading_text_data.AddState(ax::mojom::State::kEditable);
3853 heading_text_data.AddIntListAttribute(
3856 heading_text_data.AddIntListAttribute(
3858 heading_text_data.AddIntListAttribute(
3860 heading_text_data.SetName("more text");
3861
3862 ui::AXNodeData mark_data;
3863 mark_data.id = 5;
3864 mark_data.role = ax::mojom::Role::kMark;
3866 0xFFADBEEFU);
3867 mark_data.AddIntAttribute(ax::mojom::IntAttribute::kColor, 0xFFADC0DEU);
3869 mark_data.child_ids = {6};
3870
3871 ui::AXNodeData mark_text_data;
3872 mark_text_data.id = 6;
3873 mark_text_data.role = ax::mojom::Role::kStaticText;
3875 0xFFADBEEFU);
3876 mark_text_data.AddIntAttribute(ax::mojom::IntAttribute::kColor, 0xFFADC0DEU);
3879 mark_text_data.SetName("marked text");
3880
3881 ui::AXNodeData list_data;
3882 list_data.id = 7;
3883 list_data.role = ax::mojom::Role::kList;
3884 list_data.child_ids = {8, 10};
3886 0xFFADBEEFU);
3887 list_data.AddIntAttribute(ax::mojom::IntAttribute::kColor, 0xFFADC0DEU);
3888
3889 ui::AXNodeData list_item_data;
3890 list_item_data.id = 8;
3891 list_item_data.role = ax::mojom::Role::kListItem;
3892 list_item_data.child_ids = {9};
3893 list_item_data.AddIntAttribute(
3895 static_cast<int>(ax::mojom::ListStyle::kOther));
3897 0xFFADBEEFU);
3898 list_item_data.AddIntAttribute(ax::mojom::IntAttribute::kColor, 0xFFADC0DEU);
3899
3900 ui::AXNodeData list_item_text_data;
3901 list_item_text_data.id = 9;
3902 list_item_text_data.role = ax::mojom::Role::kStaticText;
3904 0xFFADBEEFU);
3906 0xFFADC0DEU);
3907 list_item_text_data.SetName("list item");
3908
3909 ui::AXNodeData list_item2_data;
3910 list_item2_data.id = 10;
3911 list_item2_data.role = ax::mojom::Role::kListItem;
3912 list_item2_data.child_ids = {11};
3913 list_item2_data.AddIntAttribute(
3915 static_cast<int>(ax::mojom::ListStyle::kDisc));
3917 0xFFADBEEFU);
3918 list_item2_data.AddIntAttribute(ax::mojom::IntAttribute::kColor, 0xFFADC0DEU);
3919
3920 ui::AXNodeData list_item2_text_data;
3921 list_item2_text_data.id = 11;
3922 list_item2_text_data.role = ax::mojom::Role::kStaticText;
3923 list_item2_text_data.AddIntAttribute(
3926 0xFFADC0DEU);
3927 list_item2_text_data.SetName("list item 2");
3928
3929 ui::AXNodeData input_text_data;
3930 input_text_data.id = 12;
3931 input_text_data.role = ax::mojom::Role::kTextField;
3932 input_text_data.AddState(ax::mojom::State::kEditable);
3933 input_text_data.AddIntAttribute(
3935 static_cast<int>(ax::mojom::NameFrom::kPlaceholder));
3937 "placeholder2");
3939 0xFFADBEEFU);
3940 input_text_data.AddIntAttribute(ax::mojom::IntAttribute::kColor, 0xFFADC0DEU);
3942 "input");
3944 "text");
3945 input_text_data.SetName("placeholder");
3946 input_text_data.child_ids = {13};
3947
3948 ui::AXNodeData placeholder_text_data;
3949 placeholder_text_data.id = 13;
3950 placeholder_text_data.role = ax::mojom::Role::kStaticText;
3951 placeholder_text_data.AddIntAttribute(
3954 0xFFADC0DEU);
3955 placeholder_text_data.SetName("placeholder");
3956
3957 ui::AXNodeData input_text_data2;
3958 input_text_data2.id = 14;
3959 input_text_data2.role = ax::mojom::Role::kTextField;
3960 input_text_data2.AddState(ax::mojom::State::kEditable);
3963 "placeholder2");
3965 0xFFADBEEFU);
3967 0xFFADC0DEU);
3969 "input");
3971 "text");
3972 input_text_data2.SetName("foo");
3973 input_text_data2.child_ids = {15};
3974
3975 ui::AXNodeData placeholder_text_data2;
3976 placeholder_text_data2.id = 15;
3977 placeholder_text_data2.role = ax::mojom::Role::kStaticText;
3978 placeholder_text_data2.AddIntAttribute(
3980 placeholder_text_data2.AddIntAttribute(ax::mojom::IntAttribute::kColor,
3981 0xFFADC0DEU);
3982 placeholder_text_data2.SetName("placeholder2");
3983
3984 ui::AXNodeData link_data;
3985 link_data.id = 16;
3986 link_data.role = ax::mojom::Role::kLink;
3988 0xFFADBEEFU);
3989 link_data.AddIntAttribute(ax::mojom::IntAttribute::kColor, 0xFFADC0DEU);
3990
3991 ui::AXNodeData link_text_data;
3992 link_text_data.id = 17;
3993 link_text_data.role = ax::mojom::Role::kStaticText;
3995 0xFFADBEEFU);
3996 link_text_data.AddIntAttribute(ax::mojom::IntAttribute::kColor, 0xFFADC0DEU);
3997 link_data.child_ids = {17};
3998
3999 ui::AXNodeData root_data;
4000 root_data.id = 1;
4002 root_data.child_ids = {2, 3, 5, 7, 12, 14, 16};
4003
4005 ui::AXTreeData tree_data;
4007 update.tree_data = tree_data;
4008 update.has_tree_data = true;
4009 update.root_id = root_data.id;
4010 update.nodes.push_back(root_data);
4011 update.nodes.push_back(text_data);
4012 update.nodes.push_back(heading_data);
4013 update.nodes.push_back(heading_text_data);
4014 update.nodes.push_back(mark_data);
4015 update.nodes.push_back(mark_text_data);
4016 update.nodes.push_back(list_data);
4017 update.nodes.push_back(list_item_data);
4018 update.nodes.push_back(list_item_text_data);
4019 update.nodes.push_back(list_item2_data);
4020 update.nodes.push_back(list_item2_text_data);
4021 update.nodes.push_back(input_text_data);
4022 update.nodes.push_back(placeholder_text_data);
4023 update.nodes.push_back(input_text_data2);
4024 update.nodes.push_back(placeholder_text_data2);
4025 update.nodes.push_back(link_data);
4026 update.nodes.push_back(link_text_data);
4027
4028 Init(update);
4029
4030 AXNode* root_node = GetRootAsAXNode();
4031 AXNode* text_node = root_node->children()[0];
4032 AXNode* heading_node = root_node->children()[1];
4033 AXNode* heading_text_node = heading_node->children()[0];
4034 AXNode* mark_node = root_node->children()[2];
4035 AXNode* mark_text_node = mark_node->children()[0];
4036 AXNode* list_node = root_node->children()[3];
4037 AXNode* list_item_node = list_node->children()[0];
4038 AXNode* list_item_text_node = list_item_node->children()[0];
4039 AXNode* list_item2_node = list_node->children()[1];
4040 AXNode* list_item2_text_node = list_item2_node->children()[0];
4041 AXNode* input_text_node = root_node->children()[4];
4042 AXNode* placeholder_text_node = input_text_node->children()[0];
4043 AXNode* input_text_node2 = root_node->children()[5];
4044 AXNode* placeholder_text_node2 = input_text_node2->children()[0];
4045 AXNode* link_node = root_node->children()[6];
4046 AXNode* link_text_node = link_node->children()[0];
4047
4048 ComPtr<ITextRangeProvider> document_range_provider;
4049 GetTextRangeProviderFromTextNode(document_range_provider, root_node);
4050 ComPtr<ITextRangeProvider> text_range_provider;
4051 GetTextRangeProviderFromTextNode(text_range_provider, text_node);
4052 ComPtr<ITextRangeProvider> heading_text_range_provider;
4053 GetTextRangeProviderFromTextNode(heading_text_range_provider,
4054 heading_text_node);
4055 ComPtr<ITextRangeProvider> mark_text_range_provider;
4056 GetTextRangeProviderFromTextNode(mark_text_range_provider, mark_text_node);
4057 ComPtr<ITextRangeProvider> list_item_text_range_provider;
4058 GetTextRangeProviderFromTextNode(list_item_text_range_provider,
4059 list_item_text_node);
4060 ComPtr<ITextRangeProvider> list_item2_text_range_provider;
4061 GetTextRangeProviderFromTextNode(list_item2_text_range_provider,
4062 list_item2_text_node);
4063
4064 ComPtr<ITextRangeProvider> placeholder_text_range_provider;
4065 GetTextRangeProviderFromTextNode(placeholder_text_range_provider,
4066 placeholder_text_node);
4067
4068 ComPtr<ITextRangeProvider> placeholder_text_range_provider2;
4069 GetTextRangeProviderFromTextNode(placeholder_text_range_provider2,
4070 placeholder_text_node2);
4071
4072 ComPtr<ITextRangeProvider> link_text_range_provider;
4073 GetTextRangeProviderFromTextNode(link_text_range_provider, link_text_node);
4074
4075 base::win::ScopedVariant expected_variant;
4076
4077 // SkColor is ARGB, COLORREF is 0BGR
4078 expected_variant.Set(static_cast<int32_t>(0x00EFBEADU));
4079 EXPECT_UIA_TEXTATTRIBUTE_EQ(text_range_provider,
4080 UIA_BackgroundColorAttributeId, expected_variant);
4081 // Important: all nodes need to have the kColor and kBackgroundColor attribute
4082 // set for this test, otherwise the following assert will fail.
4083 EXPECT_UIA_TEXTATTRIBUTE_EQ(document_range_provider,
4084 UIA_BackgroundColorAttributeId, expected_variant);
4085 expected_variant.Reset();
4086
4087 expected_variant.Set(static_cast<int32_t>(BulletStyle::BulletStyle_None));
4088 EXPECT_UIA_TEXTATTRIBUTE_EQ(list_item_text_range_provider,
4089 UIA_BulletStyleAttributeId, expected_variant);
4090 expected_variant.Reset();
4091
4092 expected_variant.Set(
4093 static_cast<int32_t>(BulletStyle::BulletStyle_FilledRoundBullet));
4094 EXPECT_UIA_TEXTATTRIBUTE_EQ(list_item2_text_range_provider,
4095 UIA_BulletStyleAttributeId, expected_variant);
4096 expected_variant.Reset();
4097
4098 {
4099 base::win::ScopedVariant lang_variant;
4100 EXPECT_HRESULT_SUCCEEDED(text_range_provider->GetAttributeValue(
4101 UIA_CultureAttributeId, lang_variant.Receive()));
4102
4103 EXPECT_EQ(lang_variant.type(), VT_I4);
4104 const LCID lcid = V_I4(lang_variant.ptr());
4105 EXPECT_EQ(LANG_FRENCH, PRIMARYLANGID(lcid));
4106 EXPECT_EQ(SUBLANG_FRENCH_CANADIAN, SUBLANGID(lcid));
4107 EXPECT_EQ(SORT_DEFAULT, SORTIDFROMLCID(lcid));
4108 }
4109
4110 std::wstring font_name = L"sans";
4111 expected_variant.Set(SysAllocString(font_name.c_str()));
4112 EXPECT_UIA_TEXTATTRIBUTE_EQ(text_range_provider, UIA_FontNameAttributeId,
4113 expected_variant);
4114 expected_variant.Reset();
4115
4116 expected_variant.Set(12.0);
4117 EXPECT_UIA_TEXTATTRIBUTE_EQ(text_range_provider, UIA_FontSizeAttributeId,
4118 expected_variant);
4119 expected_variant.Reset();
4120
4121 expected_variant.Set(300);
4122 EXPECT_UIA_TEXTATTRIBUTE_EQ(text_range_provider, UIA_FontWeightAttributeId,
4123 expected_variant);
4124 expected_variant.Reset();
4125
4126 // SkColor is ARGB, COLORREF is 0BGR
4127 expected_variant.Set(static_cast<int32_t>(0x00DEC0ADU));
4128 EXPECT_UIA_TEXTATTRIBUTE_EQ(text_range_provider,
4129 UIA_ForegroundColorAttributeId, expected_variant);
4130 EXPECT_UIA_TEXTATTRIBUTE_EQ(document_range_provider,
4131 UIA_ForegroundColorAttributeId, expected_variant);
4132 expected_variant.Reset();
4133
4134 expected_variant.Set(false);
4135 EXPECT_UIA_TEXTATTRIBUTE_EQ(text_range_provider, UIA_IsHiddenAttributeId,
4136 expected_variant);
4137 expected_variant.Reset();
4138
4139 EXPECT_UIA_TEXTATTRIBUTE_MIXED(document_range_provider,
4140 UIA_IsHiddenAttributeId);
4141
4142 expected_variant.Set(true);
4143 EXPECT_UIA_TEXTATTRIBUTE_EQ(text_range_provider, UIA_IsItalicAttributeId,
4144 expected_variant);
4145 expected_variant.Reset();
4146
4147 expected_variant.Set(false);
4148 EXPECT_UIA_TEXTATTRIBUTE_EQ(heading_text_range_provider,
4149 UIA_IsItalicAttributeId, expected_variant);
4150 expected_variant.Reset();
4151
4152 expected_variant.Set(true);
4153 EXPECT_UIA_TEXTATTRIBUTE_EQ(text_range_provider, UIA_IsReadOnlyAttributeId,
4154 expected_variant);
4155 expected_variant.Reset();
4156
4157 expected_variant.Set(false);
4158 EXPECT_UIA_TEXTATTRIBUTE_EQ(heading_text_range_provider,
4159 UIA_IsReadOnlyAttributeId, expected_variant);
4160 expected_variant.Reset();
4161
4162 expected_variant.Set(false);
4163 EXPECT_UIA_TEXTATTRIBUTE_EQ(placeholder_text_range_provider,
4164 UIA_IsReadOnlyAttributeId, expected_variant);
4165 expected_variant.Reset();
4166
4167 expected_variant.Set(true);
4168 EXPECT_UIA_TEXTATTRIBUTE_EQ(placeholder_text_range_provider2,
4169 UIA_IsReadOnlyAttributeId, expected_variant);
4170 expected_variant.Reset();
4171
4172 expected_variant.Set(true);
4173 EXPECT_UIA_TEXTATTRIBUTE_EQ(link_text_range_provider,
4174 UIA_IsReadOnlyAttributeId, expected_variant);
4175 expected_variant.Reset();
4176
4177 expected_variant.Set(HorizontalTextAlignment_Centered);
4178 EXPECT_UIA_TEXTATTRIBUTE_EQ(text_range_provider,
4179 UIA_HorizontalTextAlignmentAttributeId,
4180 expected_variant);
4181 expected_variant.Reset();
4182
4183 expected_variant.Set(HorizontalTextAlignment_Justified);
4184 EXPECT_UIA_TEXTATTRIBUTE_EQ(heading_text_range_provider,
4185 UIA_HorizontalTextAlignmentAttributeId,
4186 expected_variant);
4187 expected_variant.Reset();
4188
4189 expected_variant.Set(true);
4190 EXPECT_UIA_TEXTATTRIBUTE_EQ(text_range_provider, UIA_IsSubscriptAttributeId,
4191 expected_variant);
4192 expected_variant.Reset();
4193
4194 expected_variant.Set(false);
4195 EXPECT_UIA_TEXTATTRIBUTE_EQ(heading_text_range_provider,
4196 UIA_IsSubscriptAttributeId, expected_variant);
4197 expected_variant.Reset();
4198
4199 expected_variant.Set(false);
4200 EXPECT_UIA_TEXTATTRIBUTE_EQ(text_range_provider, UIA_IsSuperscriptAttributeId,
4201 expected_variant);
4202 expected_variant.Reset();
4203
4204 expected_variant.Set(true);
4205 EXPECT_UIA_TEXTATTRIBUTE_EQ(heading_text_range_provider,
4206 UIA_IsSuperscriptAttributeId, expected_variant);
4207 expected_variant.Reset();
4208
4209 expected_variant.Set(TextDecorationLineStyle::TextDecorationLineStyle_Dot);
4210 EXPECT_UIA_TEXTATTRIBUTE_EQ(text_range_provider, UIA_OverlineStyleAttributeId,
4211 expected_variant);
4212 expected_variant.Reset();
4213
4214 expected_variant.Set(TextDecorationLineStyle::TextDecorationLineStyle_Dash);
4216 text_range_provider, UIA_StrikethroughStyleAttributeId, expected_variant);
4217 expected_variant.Reset();
4218
4219 expected_variant.Set(TextDecorationLineStyle::TextDecorationLineStyle_Single);
4220 EXPECT_UIA_TEXTATTRIBUTE_EQ(text_range_provider,
4221 UIA_UnderlineStyleAttributeId, expected_variant);
4222 expected_variant.Reset();
4223
4224 std::wstring style_name;
4225 expected_variant.Set(SysAllocString(style_name.c_str()));
4226 EXPECT_UIA_TEXTATTRIBUTE_EQ(text_range_provider, UIA_StyleNameAttributeId,
4227 expected_variant);
4228 expected_variant.Reset();
4229
4230 expected_variant.Set(static_cast<int32_t>(StyleId_Heading6));
4231 EXPECT_UIA_TEXTATTRIBUTE_EQ(heading_text_range_provider,
4232 UIA_StyleIdAttributeId, expected_variant);
4233 expected_variant.Reset();
4234
4235 style_name = L"mark";
4236 expected_variant.Set(SysAllocString(style_name.c_str()));
4237 EXPECT_UIA_TEXTATTRIBUTE_EQ(mark_text_range_provider,
4238 UIA_StyleNameAttributeId, expected_variant);
4239 expected_variant.Reset();
4240
4241 expected_variant.Set(static_cast<int32_t>(StyleId_NumberedList));
4242 EXPECT_UIA_TEXTATTRIBUTE_EQ(list_item_text_range_provider,
4243 UIA_StyleIdAttributeId, expected_variant);
4244 expected_variant.Reset();
4245
4246 expected_variant.Set(static_cast<int32_t>(StyleId_BulletedList));
4247 EXPECT_UIA_TEXTATTRIBUTE_EQ(list_item2_text_range_provider,
4248 UIA_StyleIdAttributeId, expected_variant);
4249 expected_variant.Reset();
4250
4251 expected_variant.Set(
4252 static_cast<int32_t>(FlowDirections::FlowDirections_RightToLeft));
4254 text_range_provider, UIA_TextFlowDirectionsAttributeId, expected_variant);
4255 EXPECT_UIA_TEXTATTRIBUTE_MIXED(document_range_provider,
4256 UIA_TextFlowDirectionsAttributeId);
4257 expected_variant.Reset();
4258
4259 // Move the start endpoint back and forth one character to force such endpoint
4260 // to be located at the end of the previous anchor, this shouldn't cause
4261 // GetAttributeValue to include the previous anchor's attributes.
4262 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(mark_text_range_provider,
4263 TextPatternRangeEndpoint_Start,
4264 TextUnit_Character,
4265 /*count*/ -1,
4266 /*expected_text*/ L"tmarked text",
4267 /*expected_count*/ -1);
4268 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(mark_text_range_provider,
4269 TextPatternRangeEndpoint_Start,
4270 TextUnit_Character,
4271 /*count*/ 1,
4272 /*expected_text*/ L"marked text",
4273 /*expected_count*/ 1);
4274 expected_variant.Set(false);
4275 EXPECT_UIA_TEXTATTRIBUTE_EQ(mark_text_range_provider,
4276 UIA_IsSuperscriptAttributeId, expected_variant);
4277 expected_variant.Reset();
4278
4279 // Same idea as above, but moving forth and back the end endpoint to force it
4280 // to be located at the start of the next anchor.
4281 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(mark_text_range_provider,
4282 TextPatternRangeEndpoint_End,
4283 TextUnit_Character,
4284 /*count*/ 1,
4285 /*expected_text*/ L"marked textl",
4286 /*expected_count*/ 1);
4287 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(mark_text_range_provider,
4288 TextPatternRangeEndpoint_End,
4289 TextUnit_Character,
4290 /*count*/ -1,
4291 /*expected_text*/ L"marked text",
4292 /*expected_count*/ -1);
4293 expected_variant.Set(
4294 static_cast<int32_t>(FlowDirections::FlowDirections_RightToLeft));
4295 EXPECT_UIA_TEXTATTRIBUTE_EQ(mark_text_range_provider,
4296 UIA_TextFlowDirectionsAttributeId,
4297 expected_variant);
4298 expected_variant.Reset();
4299
4300 {
4301 // |text_node| has a grammar error on "some text", a highlight for the
4302 // first word, a spelling error for the second word, a "spelling-error"
4303 // highlight for the fourth word, and a "grammar-error" highlight for the
4304 // fifth word. So the range has mixed annotations.
4305 EXPECT_UIA_TEXTATTRIBUTE_MIXED(text_range_provider,
4306 UIA_AnnotationTypesAttributeId);
4307
4308 // Testing annotations in range [5,9)
4309 // start: TextPosition, anchor_id=2, text_offset=5,
4310 // annotated_text=some <t>ext and some other text
4311 // end : TextPosition, anchor_id=2, text_offset=9,
4312 // annotated_text=some text<> and some other text
4313 AXPlatformNodeWin* owner =
4314 static_cast<AXPlatformNodeWin*>(AXPlatformNodeFromNode(text_node));
4315 ComPtr<AXPlatformNodeTextRangeProviderWin> range_with_annotations;
4316 CreateTextRangeProviderWin(
4317 range_with_annotations, owner,
4318 /*start_anchor=*/text_node, /*start_offset=*/5,
4319 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
4320 /*end_anchor=*/text_node, /*end_offset=*/9,
4321 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
4322
4323 base::win::ScopedVariant annotation_types_variant;
4324 EXPECT_HRESULT_SUCCEEDED(range_with_annotations->GetAttributeValue(
4325 UIA_AnnotationTypesAttributeId, annotation_types_variant.Receive()));
4326
4327 EXPECT_EQ(annotation_types_variant.type(), VT_ARRAY | VT_I4);
4328 std::vector<int> expected_annotations = {AnnotationType_SpellingError,
4329 AnnotationType_GrammarError};
4330 EXPECT_UIA_SAFEARRAY_EQ(V_ARRAY(annotation_types_variant.ptr()),
4331 expected_annotations);
4332 }
4333
4334 {
4335 // Testing annotations in range [0,4)
4336 // start: TextPosition, anchor_id=2, text_offset=0,
4337 // annotated_text=<s>ome text and some other text
4338 // end : TextPosition, anchor_id=2, text_offset=4,
4339 // annotated_text=some<> text and some other text
4340 AXPlatformNodeWin* owner =
4341 static_cast<AXPlatformNodeWin*>(AXPlatformNodeFromNode(text_node));
4342 ComPtr<AXPlatformNodeTextRangeProviderWin> range_with_annotations;
4343 CreateTextRangeProviderWin(
4344 range_with_annotations, owner,
4345 /*start_anchor=*/text_node, /*start_offset=*/0,
4346 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
4347 /*end_anchor=*/text_node, /*end_offset=*/4,
4348 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
4349
4350 base::win::ScopedVariant annotation_types_variant;
4351 EXPECT_HRESULT_SUCCEEDED(range_with_annotations->GetAttributeValue(
4352 UIA_AnnotationTypesAttributeId, annotation_types_variant.Receive()));
4353
4354 EXPECT_EQ(annotation_types_variant.type(), VT_ARRAY | VT_I4);
4355 std::vector<int> expected_annotations = {AnnotationType_GrammarError,
4356 AnnotationType_Highlighted};
4357 EXPECT_UIA_SAFEARRAY_EQ(V_ARRAY(annotation_types_variant.ptr()),
4358 expected_annotations);
4359 }
4360
4361 {
4362 // Testing annotations in range [14,18)
4363 // start: TextPosition, anchor_id=2, text_offset=14,
4364 // annotated_text=some text and <s>ome other text
4365 // end : TextPosition, anchor_id=2, text_offset=18,
4366 // annotated_text=some text and some<> other text
4367 AXPlatformNodeWin* owner =
4368 static_cast<AXPlatformNodeWin*>(AXPlatformNodeFromNode(text_node));
4369 ComPtr<AXPlatformNodeTextRangeProviderWin> range_with_annotations;
4370 CreateTextRangeProviderWin(
4371 range_with_annotations, owner,
4372 /*start_anchor=*/text_node, /*start_offset=*/14,
4373 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
4374 /*end_anchor=*/text_node, /*end_offset=*/18,
4375 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
4376
4377 base::win::ScopedVariant annotation_types_variant;
4378 EXPECT_HRESULT_SUCCEEDED(range_with_annotations->GetAttributeValue(
4379 UIA_AnnotationTypesAttributeId, annotation_types_variant.Receive()));
4380
4381 EXPECT_EQ(annotation_types_variant.type(), VT_ARRAY | VT_I4);
4382 std::vector<int> expected_annotations = {AnnotationType_SpellingError};
4383 EXPECT_UIA_SAFEARRAY_EQ(V_ARRAY(annotation_types_variant.ptr()),
4384 expected_annotations);
4385 }
4386
4387 {
4388 // Testing annotations in range [19,24)
4389 // start: TextPosition, anchor_id=2, text_offset=19,
4390 // annotated_text=some text and some <o>ther text
4391 // end : TextPosition, anchor_id=2, text_offset=24,
4392 // annotated_text=some text and some other<> text
4393 AXPlatformNodeWin* owner =
4394 static_cast<AXPlatformNodeWin*>(AXPlatformNodeFromNode(text_node));
4395 ComPtr<AXPlatformNodeTextRangeProviderWin> range_with_annotations;
4396 CreateTextRangeProviderWin(
4397 range_with_annotations, owner,
4398 /*start_anchor=*/text_node, /*start_offset=*/19,
4399 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
4400 /*end_anchor=*/text_node, /*end_offset=*/24,
4401 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
4402
4403 base::win::ScopedVariant annotation_types_variant;
4404 EXPECT_HRESULT_SUCCEEDED(range_with_annotations->GetAttributeValue(
4405 UIA_AnnotationTypesAttributeId, annotation_types_variant.Receive()));
4406
4407 EXPECT_EQ(annotation_types_variant.type(), VT_ARRAY | VT_I4);
4408 std::vector<int> expected_annotations = {AnnotationType_GrammarError};
4409 EXPECT_UIA_SAFEARRAY_EQ(V_ARRAY(annotation_types_variant.ptr()),
4410 expected_annotations);
4411 }
4412
4413 {
4414 // |heading_text_node| has a spelling error for one word, and no
4415 // annotations for the remaining text, so the range has mixed annotations.
4416 EXPECT_UIA_TEXTATTRIBUTE_MIXED(heading_text_range_provider,
4417 UIA_AnnotationTypesAttributeId);
4418
4419 // start: TextPosition, anchor_id=4, text_offset=5,
4420 // annotated_text=more <t>ext
4421 // end : TextPosition, anchor_id=4, text_offset=9,
4422 // annotated_text=more text<>
4423 AXPlatformNodeWin* owner = static_cast<AXPlatformNodeWin*>(
4424 AXPlatformNodeFromNode(heading_text_node));
4425 ComPtr<AXPlatformNodeTextRangeProviderWin> range_with_annotations;
4426 CreateTextRangeProviderWin(
4427 range_with_annotations, owner,
4428 /*start_anchor=*/heading_text_node, /*start_offset=*/5,
4429 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
4430 /*end_anchor=*/heading_text_node, /*end_offset=*/9,
4431 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
4432
4433 base::win::ScopedVariant annotation_types_variant;
4434 EXPECT_HRESULT_SUCCEEDED(range_with_annotations->GetAttributeValue(
4435 UIA_AnnotationTypesAttributeId, annotation_types_variant.Receive()));
4436
4437 std::vector<int> expected_annotations = {AnnotationType_SpellingError};
4438 EXPECT_UIA_SAFEARRAY_EQ(V_ARRAY(annotation_types_variant.ptr()),
4439 expected_annotations);
4440 }
4441
4442 {
4443 base::win::ScopedVariant empty_variant;
4444 EXPECT_UIA_TEXTATTRIBUTE_EQ(mark_text_range_provider,
4445 UIA_AnnotationTypesAttributeId, empty_variant);
4446 }
4447}
#define EXPECT_UIA_TEXTATTRIBUTE_MIXED(provider, attribute)
#define EXPECT_UIA_SAFEARRAY_EQ(safearray, expected_property_values)
const VARIANT * ptr() const
void SetRestriction(ax::mojom::Restriction restriction)
void SetTextAlign(ax::mojom::TextAlign text_align)
void SetTextDirection(ax::mojom::WritingDirection text_direction)
void AddTextStyle(ax::mojom::TextStyle text_style)
void SetTextPosition(ax::mojom::TextPosition text_position)

◆ TEST_F() [34/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestITextRangeProviderGetAttributeValueAnnotationObjects   
)

Definition at line 4449 of file ax_platform_node_textrangeprovider_win_unittest.cc.

4450 {
4451 // rootWebArea id=1
4452 // ++mark id=2 detailsIds=comment1 comment2 highlighted
4453 // ++++staticText id=3 name="some text"
4454 // ++comment id=4 name="comment 1"
4455 // ++++staticText id=5 name="comment 1"
4456 // ++comment id=6 name="comment 2"
4457 // ++++staticText id=7 name="comment 2"
4458 // ++mark id=8 name="highlighted"
4459 // ++++staticText id=9 name="highlighted"
4460
4462 AXNodeData annotation_target;
4463 AXNodeData some_text;
4464 AXNodeData comment1;
4465 AXNodeData comment1_text;
4466 AXNodeData comment2;
4467 AXNodeData comment2_text;
4468 AXNodeData highlighted;
4469 AXNodeData highlighted_text;
4470
4471 root.id = 1;
4472 annotation_target.id = 2;
4473 some_text.id = 3;
4474 comment1.id = 4;
4475 comment1_text.id = 5;
4476 comment2.id = 6;
4477 comment2_text.id = 7;
4478 highlighted.id = 8;
4479 highlighted_text.id = 9;
4480
4482 root.SetName("root");
4483 root.child_ids = {annotation_target.id, comment1.id, comment2.id,
4484 highlighted.id};
4485
4486 annotation_target.role = ax::mojom::Role::kMark;
4487 annotation_target.child_ids = {some_text.id};
4488 annotation_target.AddIntListAttribute(
4490 {comment1.id, comment2.id, highlighted.id});
4491
4493 some_text.SetName("some text");
4494
4496 comment1.SetName("comment 1");
4497 comment1.child_ids = {comment1_text.id};
4498
4499 comment1_text.role = ax::mojom::Role::kStaticText;
4500 comment1_text.SetName("comment 1");
4501
4503 comment2.SetName("comment 2");
4504 comment2.child_ids = {comment2_text.id};
4505
4506 comment2_text.role = ax::mojom::Role::kStaticText;
4507 comment2_text.SetName("comment 2");
4508
4509 highlighted.role = ax::mojom::Role::kMark;
4510 highlighted.SetName("highlighted");
4511 highlighted.child_ids = {highlighted_text.id};
4512
4513 highlighted_text.role = ax::mojom::Role::kStaticText;
4514 highlighted_text.SetName("highlighted");
4515
4517 update.has_tree_data = true;
4518 update.root_id = root.id;
4519 update.nodes = {root, annotation_target, some_text,
4520 comment1, comment1_text, comment2,
4521 comment2_text, highlighted, highlighted_text};
4522 update.tree_data.tree_id = ui::AXTreeID::CreateNewAXTreeID();
4523
4524 Init(update);
4525
4526 AXNode* root_node = GetRootAsAXNode();
4527 AXNode* annotation_target_node = root_node->children()[0];
4528 AXNode* comment1_node = root_node->children()[1];
4529 AXNode* comment2_node = root_node->children()[2];
4530 AXNode* highlighted_node = root_node->children()[3];
4531
4532 ComPtr<AXPlatformNodeTextRangeProviderWin> some_text_range_provider;
4533
4534 // Create a text range encapsulates |annotation_target_node| with content
4535 // "some text".
4536 // start: TextPosition, anchor_id=2, text_offset=0, annotated_text=<s>ome text
4537 // end : TextPosition, anchor_id=2, text_offset=9, annotated_text=some text<>
4538 AXPlatformNodeWin* owner = static_cast<AXPlatformNodeWin*>(
4539 AXPlatformNodeFromNode(annotation_target_node));
4540 CreateTextRangeProviderWin(
4541 some_text_range_provider, owner,
4542 /*start_anchor=*/annotation_target_node, /*start_offset=*/0,
4543 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
4544 /*end_anchor=*/annotation_target_node, /*end_offset=*/9,
4545 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
4546 ASSERT_NE(nullptr, some_text_range_provider.Get());
4547 EXPECT_UIA_TEXTRANGE_EQ(some_text_range_provider, L"some text");
4548
4549 ComPtr<IRawElementProviderSimple> comment1_provider =
4550 QueryInterfaceFromNode<IRawElementProviderSimple>(comment1_node);
4551 ASSERT_NE(nullptr, comment1_provider.Get());
4552 ComPtr<IRawElementProviderSimple> comment2_provider =
4553 QueryInterfaceFromNode<IRawElementProviderSimple>(comment2_node);
4554 ASSERT_NE(nullptr, comment2_provider.Get());
4555 ComPtr<IRawElementProviderSimple> highlighted_provider =
4556 QueryInterfaceFromNode<IRawElementProviderSimple>(highlighted_node);
4557 ASSERT_NE(nullptr, highlighted_provider.Get());
4558
4559 ComPtr<IAnnotationProvider> annotation_provider;
4560 int annotation_type;
4561
4562 // Validate |comment1_node| with Role::kComment supports IAnnotationProvider.
4563 EXPECT_HRESULT_SUCCEEDED(comment1_provider->GetPatternProvider(
4564 UIA_AnnotationPatternId, &annotation_provider));
4565 ASSERT_NE(nullptr, annotation_provider.Get());
4566 EXPECT_HRESULT_SUCCEEDED(
4567 annotation_provider->get_AnnotationTypeId(&annotation_type));
4568 EXPECT_EQ(AnnotationType_Comment, annotation_type);
4569 annotation_provider.Reset();
4570
4571 // Validate |comment2_node| with Role::kComment supports IAnnotationProvider.
4572 EXPECT_HRESULT_SUCCEEDED(comment2_provider->GetPatternProvider(
4573 UIA_AnnotationPatternId, &annotation_provider));
4574 ASSERT_NE(nullptr, annotation_provider.Get());
4575 EXPECT_HRESULT_SUCCEEDED(
4576 annotation_provider->get_AnnotationTypeId(&annotation_type));
4577 EXPECT_EQ(AnnotationType_Comment, annotation_type);
4578 annotation_provider.Reset();
4579
4580 // Validate |highlighted_node| with Role::kMark supports
4581 // IAnnotationProvider.
4582 EXPECT_HRESULT_SUCCEEDED(highlighted_provider->GetPatternProvider(
4583 UIA_AnnotationPatternId, &annotation_provider));
4584 ASSERT_NE(nullptr, annotation_provider.Get());
4585 EXPECT_HRESULT_SUCCEEDED(
4586 annotation_provider->get_AnnotationTypeId(&annotation_type));
4587 EXPECT_EQ(AnnotationType_Highlighted, annotation_type);
4588 annotation_provider.Reset();
4589
4590 base::win::ScopedVariant annotation_objects_variant;
4591 EXPECT_HRESULT_SUCCEEDED(some_text_range_provider->GetAttributeValue(
4592 UIA_AnnotationObjectsAttributeId, annotation_objects_variant.Receive()));
4593 EXPECT_EQ(VT_UNKNOWN | VT_ARRAY, annotation_objects_variant.type());
4594
4595 std::vector<std::wstring> expected_names = {L"comment 1", L"comment 2",
4596 L"highlighted"};
4597 EXPECT_UIA_ELEMENT_ARRAY_BSTR_EQ(V_ARRAY(annotation_objects_variant.ptr()),
4598 UIA_NamePropertyId, expected_names);
4599}
#define EXPECT_UIA_ELEMENT_ARRAY_BSTR_EQ(array, element_test_property_id, expected_property_values)

◆ TEST_F() [35/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestITextRangeProviderGetAttributeValueAnnotationObjectsMixed   
)

Definition at line 4601 of file ax_platform_node_textrangeprovider_win_unittest.cc.

4602 {
4603 // rootWebArea id=1
4604 // ++mark id=2 detailsIds=comment
4605 // ++++staticText id=3 name="some text"
4606 // ++staticText id=4 name="read only" restriction=readOnly
4607 // ++comment id=5 name="comment 1"
4608 // ++++staticText id=6 name="comment 1"
4609
4611 AXNodeData highlighted;
4612 AXNodeData some_text;
4613 AXNodeData readonly_text;
4614 AXNodeData comment1;
4615 AXNodeData comment1_text;
4616
4617 root.id = 1;
4618 highlighted.id = 2;
4619 some_text.id = 3;
4620 readonly_text.id = 4;
4621 comment1.id = 5;
4622 comment1_text.id = 6;
4623
4625 root.SetName("root");
4626 root.child_ids = {highlighted.id, readonly_text.id, comment1.id};
4627
4628 highlighted.role = ax::mojom::Role::kMark;
4629 highlighted.child_ids = {some_text.id};
4631 {comment1.id});
4632
4634 some_text.SetName("some text");
4635
4636 readonly_text.role = ax::mojom::Role::kStaticText;
4638 readonly_text.SetName("read only");
4639
4641 comment1.SetName("comment 1");
4642 comment1.child_ids = {comment1_text.id};
4643
4644 comment1_text.role = ax::mojom::Role::kStaticText;
4645 comment1_text.SetName("comment 1");
4646
4648 update.has_tree_data = true;
4649 update.root_id = root.id;
4650 update.nodes = {root, highlighted, some_text,
4651 readonly_text, comment1, comment1_text};
4652 update.tree_data.tree_id = ui::AXTreeID::CreateNewAXTreeID();
4653
4654 Init(update);
4655
4656 AXNode* root_node = GetRootAsAXNode();
4657 AXNode* highlighted_node = root_node->children()[0];
4658 AXNode* some_text_node = highlighted_node->children()[0];
4659 AXNode* readonly_text_node = root_node->children()[1];
4660 AXNode* comment1_node = root_node->children()[2];
4661
4662 // Create a text range encapsulates |highlighted_node| with content
4663 // "some text".
4664 // start: TextPosition, anchor_id=2, text_offset=0, annotated_text=<s>ome text
4665 // end : TextPosition, anchor_id=2, text_offset=9, annotated_text=some text<>
4666 ComPtr<AXPlatformNodeTextRangeProviderWin> some_text_range_provider;
4667 AXPlatformNodeWin* owner =
4668 static_cast<AXPlatformNodeWin*>(AXPlatformNodeFromNode(highlighted_node));
4669 CreateTextRangeProviderWin(
4670 some_text_range_provider, owner,
4671 /*start_anchor=*/highlighted_node, /*start_offset=*/0,
4672 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
4673 /*end_anchor=*/highlighted_node, /*end_offset=*/9,
4674 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
4675 ASSERT_NE(nullptr, some_text_range_provider.Get());
4676 EXPECT_UIA_TEXTRANGE_EQ(some_text_range_provider, L"some text");
4677
4678 ComPtr<ITextRangeProvider> readonly_text_range_provider;
4679 GetTextRangeProviderFromTextNode(readonly_text_range_provider,
4680 readonly_text_node);
4681 ASSERT_NE(nullptr, readonly_text_range_provider.Get());
4682
4683 ComPtr<IRawElementProviderSimple> comment1_provider =
4684 QueryInterfaceFromNode<IRawElementProviderSimple>(comment1_node);
4685 ASSERT_NE(nullptr, comment1_provider.Get());
4686
4687 ComPtr<IAnnotationProvider> annotation_provider;
4688 int annotation_type;
4689 base::win::ScopedVariant expected_variant;
4690
4691 // Validate |comment1_node| with Role::kComment supports IAnnotationProvider.
4692 EXPECT_HRESULT_SUCCEEDED(comment1_provider->GetPatternProvider(
4693 UIA_AnnotationPatternId, &annotation_provider));
4694 ASSERT_NE(nullptr, annotation_provider.Get());
4695 EXPECT_HRESULT_SUCCEEDED(
4696 annotation_provider->get_AnnotationTypeId(&annotation_type));
4697 EXPECT_EQ(AnnotationType_Comment, annotation_type);
4698 annotation_provider.Reset();
4699
4700 // Validate text range "some text" supports AnnotationObjectsAttribute.
4701 EXPECT_HRESULT_SUCCEEDED(some_text_range_provider->GetAttributeValue(
4702 UIA_AnnotationObjectsAttributeId, expected_variant.Receive()));
4703 EXPECT_EQ(VT_UNKNOWN | VT_ARRAY, expected_variant.type());
4704
4705 std::vector<std::wstring> expected_names = {L"comment 1"};
4706 EXPECT_UIA_ELEMENT_ARRAY_BSTR_EQ(V_ARRAY(expected_variant.ptr()),
4707 UIA_NamePropertyId, expected_names);
4708 expected_variant.Reset();
4709
4710 // Validate text range "read only" supports IsReadOnlyAttribute.
4711 // Use IsReadOnly on text range "read only" as a second property in order to
4712 // test the "mixed" property in the following section.
4713 expected_variant.Set(true);
4714 EXPECT_UIA_TEXTATTRIBUTE_EQ(readonly_text_range_provider,
4715 UIA_IsReadOnlyAttributeId, expected_variant);
4716
4717 // Validate text range "some textread only" returns mixed attribute.
4718 // start: TextPosition, anchor_id=2, text_offset=0, annotated_text=<s>ome text
4719 // end : TextPosition, anchor_id=3, text_offset=9, annotated_text=read only<>
4720 ComPtr<AXPlatformNodeTextRangeProviderWin> mixed_text_range_provider;
4721 CreateTextRangeProviderWin(
4722 mixed_text_range_provider, owner,
4723 /*start_anchor=*/some_text_node, /*start_offset=*/0,
4724 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
4725 /*end_anchor=*/readonly_text_node, /*end_offset=*/9,
4726 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
4727
4728 EXPECT_UIA_TEXTRANGE_EQ(mixed_text_range_provider, L"some textread only");
4729 EXPECT_UIA_TEXTATTRIBUTE_MIXED(mixed_text_range_provider,
4730 UIA_AnnotationObjectsAttributeId);
4731}

◆ TEST_F() [36/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestITextRangeProviderGetBoundingRectangles   
)

Definition at line 3153 of file ax_platform_node_textrangeprovider_win_unittest.cc.

3154 {
3155 ui::AXTreeUpdate update = BuildAXTreeForBoundingRectangles();
3156 Init(update);
3157 ComPtr<ITextRangeProvider> text_range_provider;
3158 base::win::ScopedSafearray rectangles;
3159 int units_moved;
3160
3161 // Expected bounding rects:
3162 // <button>Button</button><input type="checkbox">Line 1<br>Line 2
3163 // |---------------------||---------------------||----| |------|
3164 GetTextRangeProviderFromTextNode(text_range_provider, GetRootAsAXNode());
3165 EXPECT_HRESULT_SUCCEEDED(
3166 text_range_provider->GetBoundingRectangles(rectangles.Receive()));
3167 std::vector<double> expected_values = {20, 20, 200, 30, /* button */
3168 20, 50, 200, 30, /* check box */
3169 220, 20, 30, 30, /* line 1 */
3170 220, 50, 42, 30 /* line 2 */};
3171 EXPECT_UIA_SAFEARRAY_EQ(rectangles.Get(), expected_values);
3172 rectangles.Reset();
3173
3174 // Move the text range end back by one character.
3175 // Expected bounding rects:
3176 // <button>Button</button><input type="checkbox">Line 1<br>Line 2
3177 // |---------------------||---------------------||----| |----|
3178 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
3179 TextPatternRangeEndpoint_End, TextUnit_Character, /*count*/ -1,
3180 &units_moved));
3181 ASSERT_EQ(-1, units_moved);
3182 EXPECT_HRESULT_SUCCEEDED(
3183 text_range_provider->GetBoundingRectangles(rectangles.Receive()));
3184 expected_values = {20, 20, 200, 30, /* button */
3185 20, 50, 200, 30, /* check box */
3186 220, 20, 30, 30, /* line 1 */
3187 220, 50, 35, 30 /* line 2 */};
3188 EXPECT_UIA_SAFEARRAY_EQ(rectangles.Get(), expected_values);
3189 rectangles.Reset();
3190
3191 // Move the text range end back by one line.
3192 // Expected bounding rects:
3193 // <button>Button</button><input type="checkbox">Line 1<br>Line 2
3194 // |---------------------||---------------------||--------|
3195 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
3196 TextPatternRangeEndpoint_End, TextUnit_Line, /*count*/ -1, &units_moved));
3197 ASSERT_EQ(-1, units_moved);
3198 EXPECT_HRESULT_SUCCEEDED(
3199 text_range_provider->GetBoundingRectangles(rectangles.Receive()));
3200 expected_values = {20, 20, 200, 30, /* button */
3201 20, 50, 200, 30, /* check box */
3202 220, 20, 30, 30 /* line 1 */};
3203 EXPECT_UIA_SAFEARRAY_EQ(rectangles.Get(), expected_values);
3204 rectangles.Reset();
3205
3206 // Move the text range end back by one line.
3207 // Expected bounding rects:
3208 // <button>Button</button><input type="checkbox">Line 1<br>Line 2
3209 // |---------------------||---------------------|
3210 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
3211 TextPatternRangeEndpoint_End, TextUnit_Word, /*count*/ -3, &units_moved));
3212 ASSERT_EQ(-3, units_moved);
3213 EXPECT_HRESULT_SUCCEEDED(
3214 text_range_provider->GetBoundingRectangles(rectangles.Receive()));
3215 expected_values = {20, 20, 200, 30, /* button */
3216 20, 50, 200, 30 /* check box */};
3217 EXPECT_UIA_SAFEARRAY_EQ(rectangles.Get(), expected_values);
3218}

◆ TEST_F() [37/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestITextRangeProviderIgnoredForTextNavigation   
)

Definition at line 1680 of file ax_platform_node_textrangeprovider_win_unittest.cc.

1681 {
1682 // ++1 kRootWebArea
1683 // ++++2 kStaticText
1684 // ++++++3 kInlineTextBox foo
1685 // ++++4 kSplitter
1686 // ++++5 kStaticText
1687 // ++++++6 kInlineTextBox bar
1688 // ++++7 genericContainer
1689 // ++++8 kStaticText
1690 // ++++++9 kInlineTextBox baz
1691 ui::AXNodeData root_1;
1692 ui::AXNodeData static_text_2;
1693 ui::AXNodeData inline_box_3;
1694 ui::AXNodeData splitter_4;
1695 ui::AXNodeData static_text_5;
1696 ui::AXNodeData inline_box_6;
1697 ui::AXNodeData generic_container_7;
1698 ui::AXNodeData static_text_8;
1699 ui::AXNodeData inline_box_9;
1700
1701 root_1.id = 1;
1702 static_text_2.id = 2;
1703 inline_box_3.id = 3;
1704 splitter_4.id = 4;
1705 static_text_5.id = 5;
1706 inline_box_6.id = 6;
1707 generic_container_7.id = 7;
1708 static_text_8.id = 8;
1709 inline_box_9.id = 9;
1710
1712 root_1.child_ids = {static_text_2.id, splitter_4.id, static_text_5.id,
1713 generic_container_7.id, static_text_8.id};
1714
1715 static_text_2.role = ax::mojom::Role::kStaticText;
1716 static_text_2.child_ids = {inline_box_3.id};
1717 static_text_2.SetName("foo");
1718
1720 inline_box_3.SetName("foo");
1721
1722 splitter_4.role = ax::mojom::Role::kSplitter;
1724 true);
1725
1726 static_text_5.role = ax::mojom::Role::kStaticText;
1727 static_text_5.child_ids = {inline_box_6.id};
1728 static_text_5.SetName("bar");
1729
1731 inline_box_6.SetName("bar");
1732
1733 generic_container_7.role = ax::mojom::Role::kGenericContainer;
1734 generic_container_7.AddBoolAttribute(
1736
1737 static_text_8.role = ax::mojom::Role::kStaticText;
1738 static_text_8.child_ids = {inline_box_9.id};
1739 static_text_8.SetName("bar");
1740
1742 inline_box_9.SetName("baz");
1743
1745 ui::AXTreeData tree_data;
1747 update.tree_data = tree_data;
1748 update.has_tree_data = true;
1749 update.root_id = root_1.id;
1750 update.nodes = {
1751 root_1, static_text_2, inline_box_3, splitter_4,
1752 static_text_5, inline_box_6, generic_container_7, static_text_8,
1753 inline_box_9};
1754
1755 Init(update);
1756
1757 AXNode* root_node = GetRootAsAXNode();
1758 ComPtr<ITextRangeProvider> text_range_provider;
1759 GetTextRangeProviderFromTextNode(text_range_provider, root_node);
1760
1761 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider,
1762 L"foo\n\xFFFC\nbar\n\xFFFC\nbaz");
1763
1764 int count;
1765 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1766 TextPatternRangeEndpoint_Start, TextUnit_Paragraph, /*count*/ 1, &count));
1767 ASSERT_EQ(1, count);
1768 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"bar\n\xFFFC\nbaz");
1769
1770 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1771 TextPatternRangeEndpoint_Start, TextUnit_Paragraph, /*count*/ 1, &count));
1772 ASSERT_EQ(1, count);
1773 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"baz");
1774}

◆ TEST_F() [38/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestITextRangeProviderIgnoredNodes   
)

Definition at line 5836 of file ax_platform_node_textrangeprovider_win_unittest.cc.

5837 {
5838 // Parent Tree
5839 // 1
5840 // |
5841 // 2(i)
5842 // |________________________________
5843 // | | | | | |
5844 // 3 4 5 6 7(i) 8(i)
5845 // | |________
5846 // | | |
5847 // 9(i) 10(i) 11
5848 // | |____
5849 // | | |
5850 // 12 13 14
5851
5852 ui::AXTreeUpdate tree_update;
5854 tree_update.tree_data.tree_id = tree_id;
5855 tree_update.has_tree_data = true;
5856 tree_update.root_id = 1;
5857 tree_update.nodes.resize(14);
5858 tree_update.nodes[0].id = 1;
5859 tree_update.nodes[0].child_ids = {2};
5860 tree_update.nodes[0].role = ax::mojom::Role::kRootWebArea;
5861
5862 tree_update.nodes[1].id = 2;
5863 tree_update.nodes[1].child_ids = {3, 4, 5, 6, 7, 8};
5864 // According to the existing Blink code, editable roots are never ignored.
5865 // However, we can still create this tree structure only for test purposes.
5866 tree_update.nodes[1].AddState(ax::mojom::State::kIgnored);
5867 tree_update.nodes[1].AddState(ax::mojom::State::kEditable);
5868 tree_update.nodes[1].AddState(ax::mojom::State::kRichlyEditable);
5869 // tree_update.nodes[1].AddBoolAttribute(
5870 // ax::mojom::BoolAttribute::kNonAtomicTextFieldRoot, true);
5871 tree_update.nodes[1].role = ax::mojom::Role::kGenericContainer;
5872
5873 tree_update.nodes[2].id = 3;
5874 tree_update.nodes[2].role = ax::mojom::Role::kStaticText;
5875 tree_update.nodes[2].SetName(".3.");
5876
5877 tree_update.nodes[3].id = 4;
5878 tree_update.nodes[3].role = ax::mojom::Role::kStaticText;
5879 tree_update.nodes[3].SetName(".4.");
5880
5881 tree_update.nodes[4].id = 5;
5882 tree_update.nodes[4].role = ax::mojom::Role::kStaticText;
5883 tree_update.nodes[4].SetName(".5.");
5884
5885 tree_update.nodes[5].id = 6;
5886 tree_update.nodes[5].role = ax::mojom::Role::kButton;
5887 tree_update.nodes[5].child_ids = {9};
5888
5889 tree_update.nodes[6].id = 7;
5890 tree_update.nodes[6].child_ids = {10, 11};
5891 tree_update.nodes[6].AddState(ax::mojom::State::kIgnored);
5892 tree_update.nodes[6].role = ax::mojom::Role::kGenericContainer;
5893
5894 tree_update.nodes[7].id = 8;
5895 tree_update.nodes[7].AddState(ax::mojom::State::kIgnored);
5896 tree_update.nodes[7].role = ax::mojom::Role::kStaticText;
5897 tree_update.nodes[7].SetName(".8.");
5898
5899 tree_update.nodes[8].id = 9;
5900 tree_update.nodes[8].child_ids = {12};
5901 tree_update.nodes[8].AddState(ax::mojom::State::kIgnored);
5902 tree_update.nodes[8].role = ax::mojom::Role::kGenericContainer;
5903
5904 tree_update.nodes[9].id = 10;
5905 tree_update.nodes[9].child_ids = {13, 14};
5906 tree_update.nodes[9].AddState(ax::mojom::State::kIgnored);
5907 tree_update.nodes[8].role = ax::mojom::Role::kGenericContainer;
5908
5909 tree_update.nodes[10].id = 11;
5910 tree_update.nodes[10].role = ax::mojom::Role::kStaticText;
5911 tree_update.nodes[10].SetName(".11.");
5912
5913 tree_update.nodes[11].id = 12;
5914 tree_update.nodes[11].role = ax::mojom::Role::kStaticText;
5915 tree_update.nodes[11].AddState(ax::mojom::State::kIgnored);
5916 tree_update.nodes[11].SetName(".12.");
5917
5918 tree_update.nodes[12].id = 13;
5919 tree_update.nodes[12].role = ax::mojom::Role::kStaticText;
5920 tree_update.nodes[12].SetName(".13.");
5921
5922 tree_update.nodes[13].id = 14;
5923 tree_update.nodes[13].role = ax::mojom::Role::kStaticText;
5924 tree_update.nodes[13].SetName(".14.");
5925
5926 Init(tree_update);
5927 EXPECT_ENCLOSING_ELEMENT(GetNodeFromTree(tree_id, 1),
5928 GetNodeFromTree(tree_id, 1));
5929 EXPECT_ENCLOSING_ELEMENT(GetNodeFromTree(tree_id, 2),
5930 GetNodeFromTree(tree_id, 1));
5931 EXPECT_ENCLOSING_ELEMENT(GetNodeFromTree(tree_id, 3),
5932 GetNodeFromTree(tree_id, 3));
5933 EXPECT_ENCLOSING_ELEMENT(GetNodeFromTree(tree_id, 4),
5934 GetNodeFromTree(tree_id, 4));
5935 EXPECT_ENCLOSING_ELEMENT(GetNodeFromTree(tree_id, 5),
5936 GetNodeFromTree(tree_id, 5));
5937 EXPECT_ENCLOSING_ELEMENT(GetNodeFromTree(tree_id, 8),
5938 GetNodeFromTree(tree_id, 1));
5939 EXPECT_ENCLOSING_ELEMENT(GetNodeFromTree(tree_id, 11),
5940 GetNodeFromTree(tree_id, 11));
5941 EXPECT_ENCLOSING_ELEMENT(GetNodeFromTree(tree_id, 13),
5942 GetNodeFromTree(tree_id, 13));
5943 EXPECT_ENCLOSING_ELEMENT(GetNodeFromTree(tree_id, 14),
5944 GetNodeFromTree(tree_id, 14));
5945
5946 // Test movement and GetText()
5947 ComPtr<ITextRangeProvider> text_range_provider;
5948 GetTextRangeProviderFromTextNode(text_range_provider,
5949 GetNodeFromTree(tree_id, 1));
5950
5951 ASSERT_HRESULT_SUCCEEDED(
5952 text_range_provider->ExpandToEnclosingUnit(TextUnit_Character));
5953 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L".");
5954
5956 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Character,
5957 /*count*/ 2,
5958 /*expected_text*/ L".3.",
5959 /*expected_count*/ 2);
5960
5962 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Character,
5963 /*count*/ 6,
5964 /*expected_text*/ L".3..4..5.",
5965 /*expected_count*/ 6);
5966
5967 // By design, empty objects, such as the unlabelled button in this case, are
5968 // placed in their own paragraph for easier screen reader navigation.
5970 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Character,
5971 /*count*/ 15,
5972 /*expected_text*/ L".3..4..5.\n\xFFFC\n.13..14..11.",
5973 /*expected_count*/ 15);
5974}
#define EXPECT_ENCLOSING_ELEMENT(ax_node_given, ax_node_expected)

◆ TEST_F() [39/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestITextRangeProviderInvalidCalls   
)

Definition at line 1778 of file ax_platform_node_textrangeprovider_win_unittest.cc.

1779 {
1780 // Test for when a text range provider is invalid. Because no ax tree is
1781 // available, the anchor is invalid, so the text range provider fails the
1782 // validate call.
1783 {
1784 Init(BuildTextDocument({}));
1785
1786 ComPtr<ITextRangeProvider> text_range_provider;
1787 GetTextRangeProviderFromTextNode(text_range_provider, GetRootAsAXNode());
1788
1789 DestroyTree();
1790 ComPtr<ITextRangeProvider> text_range_provider_clone;
1792 text_range_provider->Clone(&text_range_provider_clone));
1793
1794 BOOL compare_result;
1795 EXPECT_UIA_ELEMENTNOTAVAILABLE(text_range_provider->Compare(
1796 text_range_provider.Get(), &compare_result));
1797
1798 int compare_endpoints_result;
1799 EXPECT_UIA_ELEMENTNOTAVAILABLE(text_range_provider->CompareEndpoints(
1800 TextPatternRangeEndpoint_Start, text_range_provider.Get(),
1801 TextPatternRangeEndpoint_Start, &compare_endpoints_result));
1802
1803 VARIANT attr_val;
1804 V_VT(&attr_val) = VT_BOOL;
1805 V_BOOL(&attr_val) = VARIANT_TRUE;
1806 ComPtr<ITextRangeProvider> matched_range_provider;
1807 EXPECT_UIA_ELEMENTNOTAVAILABLE(text_range_provider->FindAttribute(
1808 UIA_IsHiddenAttributeId, attr_val, true, &matched_range_provider));
1809
1810 EXPECT_UIA_ELEMENTNOTAVAILABLE(text_range_provider->MoveEndpointByRange(
1811 TextPatternRangeEndpoint_Start, text_range_provider.Get(),
1812 TextPatternRangeEndpoint_Start));
1813
1814 EXPECT_UIA_ELEMENTNOTAVAILABLE(text_range_provider->Select());
1815 }
1816
1817 // Test for when this provider is valid, but the other provider is not an
1818 // instance of AXPlatformNodeTextRangeProviderWin, so no operation can be
1819 // performed on the other provider.
1820 {
1821 Init(BuildTextDocument({}));
1822
1823 ComPtr<ITextRangeProvider> this_provider;
1824 GetTextRangeProviderFromTextNode(this_provider, GetRootAsAXNode());
1825
1826 ComPtr<ITextRangeProvider> other_provider_different_type;
1827 MockAXPlatformNodeTextRangeProviderWin::CreateMockTextRangeProvider(
1828 &other_provider_different_type);
1829
1830 BOOL compare_result;
1831 EXPECT_UIA_INVALIDOPERATION(this_provider->Compare(
1832 other_provider_different_type.Get(), &compare_result));
1833
1834 int compare_endpoints_result;
1835 EXPECT_UIA_INVALIDOPERATION(this_provider->CompareEndpoints(
1836 TextPatternRangeEndpoint_Start, other_provider_different_type.Get(),
1837 TextPatternRangeEndpoint_Start, &compare_endpoints_result));
1838
1839 EXPECT_UIA_INVALIDOPERATION(this_provider->MoveEndpointByRange(
1840 TextPatternRangeEndpoint_Start, other_provider_different_type.Get(),
1841 TextPatternRangeEndpoint_Start));
1842 }
1843}
#define EXPECT_UIA_ELEMENTNOTAVAILABLE(expr)

◆ TEST_F() [40/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestITextRangeProviderMoveDocument   
)

Definition at line 2458 of file ax_platform_node_textrangeprovider_win_unittest.cc.

2459 {
2460 Init(BuildAXTreeForMove());
2461 AXNode* root_node = GetRootAsAXNode();
2462
2463 ComPtr<ITextRangeProvider> text_range_provider;
2464 GetTextRangeProviderFromTextNode(text_range_provider, root_node);
2465
2466 // Moving by 0 should have no effect.
2467 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Document, /*count*/ 0,
2468 /*expected_text*/ tree_for_move_full_text.data(),
2469 /*expected_count*/ 0);
2470
2471 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Document, /*count*/ -1,
2472 /*expected_text*/ tree_for_move_full_text.data(),
2473 /*expected_count*/ 0);
2474 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Document, /*count*/ 2,
2475 /*expected_text*/ tree_for_move_full_text.data(),
2476 /*expected_count*/ 0);
2477 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Page, /*count*/ 1,
2478 /*expected_text*/ tree_for_move_full_text.data(),
2479 /*expected_count*/ 0);
2480 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Page, /*count*/ -1,
2481 /*expected_text*/ tree_for_move_full_text.data(),
2482 /*expected_count*/ 0);
2483
2484 // Degenerate range moves.
2486 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Document,
2487 /*count*/ -2,
2488 /*expected_text*/ L"",
2489 /*expected_count*/ -1);
2490 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Page,
2491 /*count*/ 4,
2492 /*expected_text*/ L"",
2493 /*expected_count*/ 1);
2494
2495 // Trying to move past the last character should have no effect.
2496 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Document,
2497 /*count*/ 1,
2498 /*expected_text*/ L"",
2499 /*expected_count*/ 0);
2500 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Page,
2501 /*count*/ -2,
2502 /*expected_text*/ L"",
2503 /*expected_count*/ -1);
2504 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Document,
2505 /*count*/ -1,
2506 /*expected_text*/ L"",
2507 /*expected_count*/ 0);
2508}

◆ TEST_F() [41/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestITextRangeProviderMoveEndpointByCharacterMultilingual   
)

Definition at line 2588 of file ax_platform_node_textrangeprovider_win_unittest.cc.

2589 {
2590 // The English string has three characters, each 8 bits in length.
2591 const std::string english = "hey";
2592
2593 // The Hindi string has two characters, the first one 32 bits and the second
2594 // 64 bits in length. It is formatted in UTF16.
2595 const std::string hindi =
2596 base::UTF16ToUTF8(u"\x0939\x093F\x0928\x094D\x0926\x0940");
2597
2598 // The Thai string has three characters, the first one 48, the second 32 and
2599 // the last one 16 bits in length. It is formatted in UTF16.
2600 const std::string thai =
2601 base::UTF16ToUTF8(u"\x0E23\x0E39\x0E49\x0E2A\x0E36\x0E01");
2602
2603 Init(BuildTextDocument({english, hindi, thai}));
2604
2605 ComPtr<ITextRangeProvider> text_range_provider;
2606 GetTextRangeProviderFromTextNode(text_range_provider,
2607 GetRootAsAXNode()->children()[0]);
2608
2609 // Verify MoveEndpointByUnit with zero count has no effect
2610 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"hey");
2612 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Character,
2613 /*count*/ 0,
2614 /*expected_text*/ L"hey",
2615 /*expected_count*/ 0);
2616
2618 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Character,
2619 /*count*/ 1,
2620 /*expected_text*/ L"ey",
2621 /*expected_count*/ 1);
2622
2624 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Character,
2625 /*count*/ -1,
2626 /*expected_text*/ L"e",
2627 /*expected_count*/ -1);
2628
2629 // Move end into the adjacent node.
2630 //
2631 // The first character of the second node is 32 bits in length.
2633 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Character,
2634 /*count*/ 2,
2635 /*expected_text*/ L"ey\x0939\x093F",
2636 /*expected_count*/ 2);
2637
2638 // The second character of the second node is 64 bits in length.
2640 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Character,
2641 /*count*/ 1,
2642 /*expected_text*/ L"ey\x939\x93F\x928\x94D\x926\x940",
2643 /*expected_count*/ 1);
2644
2645 // Move start into the adjacent node as well.
2647 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Character,
2648 /*count*/ 2,
2649 /*expected_text*/ L"\x939\x93F\x928\x94D\x926\x940",
2650 /*expected_count*/ 2);
2651
2652 // Move end into the last node.
2653 //
2654 // The first character of the last node is 48 bits in length.
2656 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Character,
2657 /*count*/ 1,
2658 /*expected_text*/ L"\x939\x93F\x928\x94D\x926\x940\xE23\xE39\xE49",
2659 /*expected_count*/ 1);
2660
2661 // Move end back into the second node and then into the last node again.
2663 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Character,
2664 /*count*/ -2,
2665 /*expected_text*/ L"\x939\x93F",
2666 /*expected_count*/ -2);
2667
2669 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Character,
2670 /*count*/ 3,
2671 /*expected_text*/
2672 L"\x939\x93F\x928\x94D\x926\x940\xE23\xE39\xE49\xE2A\xE36",
2673 /*expected_count*/ 3);
2674
2675 // The last character of the last node is only 16 bits in length.
2677 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Character,
2678 /*count*/ 1,
2679 /*expected_text*/
2680 L"\x939\x93F\x928\x94D\x926\x940\xE23\xE39\xE49\xE2A\xE36\xE01",
2681 /*expected_count*/ 1);
2682
2683 // Move start into the last node.
2685 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Character,
2686 /*count*/ 3,
2687 /*expected_text*/ L"\x0E2A\x0E36\x0E01",
2688 /*expected_count*/ 3);
2689
2691 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Character,
2692 /*count*/ -1,
2693 /*expected_text*/ L"\x0E23\x0E39\x0E49\x0E2A\x0E36\x0E01",
2694 /*expected_count*/ -1);
2695}
std::string UTF16ToUTF8(std::u16string src)
Definition: string_utils.cc:71

◆ TEST_F() [42/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestITextRangeProviderMoveEndpointByFormat   
)

Definition at line 3039 of file ax_platform_node_textrangeprovider_win_unittest.cc.

3040 {
3041 Init(BuildAXTreeForMoveByFormat());
3042 AXNode* root_node = GetRootAsAXNode();
3043
3044 ComPtr<ITextRangeProvider> text_range_provider;
3045 GetTextRangeProviderFromTextNode(text_range_provider, root_node);
3046
3048 text_range_provider,
3049 L"Text with formatting\nStandalone line with no formatting\nbold "
3050 L"text\nParagraph 1\nParagraph 2\nParagraph 3\nParagraph 4");
3052 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Format,
3053 /*count*/ -2,
3054 /*expected_text*/
3055 L"Text with formatting\nStandalone line with no formatting\nbold "
3056 L"text\nParagraph 1",
3057 /*expected_count*/ -2);
3058
3060 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Format,
3061 /*count*/ -1,
3062 /*expected_text*/
3063 L"Text with formatting\nStandalone line with no formatting\nbold text",
3064 /*expected_count*/ -1);
3065
3067 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Format,
3068 /*count*/ -1,
3069 /*expected_text*/
3070 L"Text with formatting\nStandalone line with no formatting\n",
3071 /*expected_count*/ -1);
3072
3074 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Format,
3075 /*count*/ -1,
3076 /*expected_text*/ L"Text with formatting",
3077 /*expected_count*/ -1);
3078
3080 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Format,
3081 /*count*/ -1,
3082 /*expected_text*/ L"",
3083 /*expected_count*/ -1);
3084
3086 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Format,
3087 /*count*/ 7,
3088 /*expected_text*/
3089 L"Text with formatting\nStandalone line with no formatting\nbold "
3090 L"text\nParagraph 1\nParagraph 2\nParagraph 3\nParagraph 4",
3091 /*expected_count*/ 6);
3092
3094 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Format,
3095 /*count*/ -8,
3096 /*expected_text*/ L"",
3097 /*expected_count*/ -6);
3098}

◆ TEST_F() [43/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestITextRangeProviderMoveEndpointByLine   
)

Definition at line 2797 of file ax_platform_node_textrangeprovider_win_unittest.cc.

2798 {
2799 Init(BuildTextDocument({"0", "1", "2", "3", "4", "5", "6"}));
2800
2801 ComPtr<ITextRangeProvider> text_range_provider;
2802 GetTextRangeProviderFromTextNode(text_range_provider,
2803 GetRootAsAXNode()->children()[3]);
2804 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"3");
2805
2806 // Moving with zero count does not alter the range.
2807 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(text_range_provider,
2808 TextPatternRangeEndpoint_End, TextUnit_Line,
2809 /*count*/ 0,
2810 /*expected_text*/ L"3",
2811 /*expected_count*/ 0);
2812
2813 // Moving the start backward and forward.
2815 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Line,
2816 /*count*/ -2,
2817 /*expected_text*/ L"123",
2818 /*expected_count*/ -2);
2820 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Line,
2821 /*count*/ 1,
2822 /*expected_text*/ L"23",
2823 /*expected_count*/ 1);
2824
2825 // Moving the end forward and backward.
2826 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(text_range_provider,
2827 TextPatternRangeEndpoint_End, TextUnit_Line,
2828 /*count*/ 3,
2829 /*expected_text*/ L"23456",
2830 /*expected_count*/ 3);
2831 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(text_range_provider,
2832 TextPatternRangeEndpoint_End, TextUnit_Line,
2833 /*count*/ -2,
2834 /*expected_text*/ L"234",
2835 /*expected_count*/ -2);
2836
2837 // Moving the end past the start and vice versa.
2838 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(text_range_provider,
2839 TextPatternRangeEndpoint_End, TextUnit_Line,
2840 /*count*/ -4,
2841 /*expected_text*/ L"",
2842 /*expected_count*/ -4);
2844 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Line,
2845 /*count*/ -1,
2846 /*expected_text*/ L"0",
2847 /*expected_count*/ -1);
2849 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Line,
2850 /*count*/ 6,
2851 /*expected_text*/ L"",
2852 /*expected_count*/ 6);
2854 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Line,
2855 /*count*/ -6,
2856 /*expected_text*/ L"012345",
2857 /*expected_count*/ -6);
2858
2859 // Moving the endpoints further than both ends of the document.
2860 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(text_range_provider,
2861 TextPatternRangeEndpoint_End, TextUnit_Line,
2862 /*count*/ -13,
2863 /*expected_text*/ L"",
2864 /*expected_count*/ -6);
2865 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(text_range_provider,
2866 TextPatternRangeEndpoint_End, TextUnit_Line,
2867 /*count*/ 11,
2868 /*expected_text*/ L"0123456",
2869 /*expected_count*/ 7);
2871 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Line,
2872 /*count*/ 9,
2873 /*expected_text*/ L"",
2874 /*expected_count*/ 7);
2876 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Line,
2877 /*count*/ -7,
2878 /*expected_text*/ L"0123456",
2879 /*expected_count*/ -7);
2880}

◆ TEST_F() [44/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestITextRangeProviderMoveEndpointByUnitTextField   
)

Definition at line 2884 of file ax_platform_node_textrangeprovider_win_unittest.cc.

2885 {
2886 // An empty text field should also be a character, word, and line boundary.
2887 ui::AXNodeData root_data;
2888 root_data.id = 1;
2890
2891 ui::AXNodeData group1_data;
2892 group1_data.id = 2;
2894
2895 ui::AXNodeData text_data;
2896 text_data.id = 3;
2898 std::string text_content = "some text";
2899 text_data.SetName(text_content);
2900 std::vector<int> word_start_offsets, word_end_offsets;
2901 ComputeWordBoundariesOffsets(text_content, word_start_offsets,
2902 word_end_offsets);
2904 word_start_offsets);
2906 word_end_offsets);
2907
2908 ui::AXNodeData text_input_data;
2909 text_input_data.id = 4;
2910 text_input_data.role = ax::mojom::Role::kTextField;
2911 text_input_data.AddState(ax::mojom::State::kEditable);
2913 "input");
2915 "text");
2916
2917 ui::AXNodeData group2_data;
2918 group2_data.id = 5;
2920
2921 ui::AXNodeData more_text_data;
2922 more_text_data.id = 6;
2923 more_text_data.role = ax::mojom::Role::kStaticText;
2924 text_content = "more text";
2925 more_text_data.SetName(text_content);
2926 ComputeWordBoundariesOffsets(text_content, word_start_offsets,
2927 word_end_offsets);
2929 word_start_offsets);
2931 word_end_offsets);
2932
2933 ui::AXNodeData empty_text_data;
2934 empty_text_data.id = 7;
2935 empty_text_data.role = ax::mojom::Role::kStaticText;
2936 empty_text_data.AddState(ax::mojom::State::kEditable);
2937 text_content = "";
2938 empty_text_data.SetNameExplicitlyEmpty();
2939 ComputeWordBoundariesOffsets(text_content, word_start_offsets,
2940 word_end_offsets);
2942 word_start_offsets);
2944 word_end_offsets);
2945
2946 root_data.child_ids = {group1_data.id, text_input_data.id, group2_data.id};
2947 group1_data.child_ids = {text_data.id};
2948 text_input_data.child_ids = {empty_text_data.id};
2949 group2_data.child_ids = {more_text_data.id};
2950
2952 ui::AXTreeData tree_data;
2954 update.tree_data = tree_data;
2955 update.has_tree_data = true;
2956 update.root_id = root_data.id;
2957 update.nodes = {root_data, group1_data, text_data, text_input_data,
2958 group2_data, more_text_data, empty_text_data};
2959
2960 Init(update);
2961
2962 // Set up variables from the tree for testing.
2963 AXNode* root_node = GetRootAsAXNode();
2964 AXNode* text_node = root_node->children()[0]->children()[0];
2965
2966 ComPtr<ITextRangeProvider> text_range_provider;
2967 GetTextRangeProviderFromTextNode(text_range_provider, text_node);
2968
2969 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"some text");
2970
2971 int count;
2972 // Tests for TextUnit_Character.
2973 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
2974 TextPatternRangeEndpoint_End, TextUnit_Character, /*count*/ 2, &count));
2975 ASSERT_EQ(2, count);
2976 // Note that by design, empty objects such as empty text fields, are placed in
2977 // their own paragraph for easier screen reader navigation.
2978 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"some text\n\xFFFc");
2979
2980 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
2981 TextPatternRangeEndpoint_End, TextUnit_Character, /*count*/ 2, &count));
2982 ASSERT_EQ(2, count);
2983 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"some text\n\xFFFc\nm");
2984
2985 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
2986 TextPatternRangeEndpoint_End, TextUnit_Character, /*count*/ -1, &count));
2987 ASSERT_EQ(-1, count);
2988 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"some text\n\xFFFC\n");
2989
2990 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
2991 TextPatternRangeEndpoint_End, TextUnit_Character, /*count*/ -2, &count));
2992 ASSERT_EQ(-2, count);
2993 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"some text\n");
2994
2995 // Tests for TextUnit_Word.
2996 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
2997 TextPatternRangeEndpoint_End, TextUnit_Word, /*count*/ 1, &count));
2998 ASSERT_EQ(1, count);
2999 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"some text\n\xFFFC\n");
3000
3001 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
3002 TextPatternRangeEndpoint_End, TextUnit_Word, /*count*/ 1, &count));
3003 ASSERT_EQ(1, count);
3004 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"some text\n\xFFFC\nmore ");
3005
3006 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
3007 TextPatternRangeEndpoint_End, TextUnit_Word, /*count*/ -1, &count));
3008 ASSERT_EQ(-1, count);
3009 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"some text\n\xFFFC\n");
3010
3011 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
3012 TextPatternRangeEndpoint_End, TextUnit_Word, /*count*/ -1, &count));
3013 ASSERT_EQ(-1, count);
3014 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"some text\n");
3015
3016 // Tests for TextUnit_Line.
3017 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
3018 TextPatternRangeEndpoint_End, TextUnit_Line, /*count*/ 1, &count));
3019 ASSERT_EQ(1, count);
3020 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"some text\n\xFFFC");
3021
3022 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
3023 TextPatternRangeEndpoint_End, TextUnit_Line, /*count*/ 1, &count));
3024 ASSERT_EQ(1, count);
3025 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"some text\n\xFFFC\nmore text");
3026
3027 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
3028 TextPatternRangeEndpoint_End, TextUnit_Line, /*count*/ -1, &count));
3029 ASSERT_EQ(-1, count);
3030 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"some text\n\xFFFC");
3031
3032 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
3033 TextPatternRangeEndpoint_End, TextUnit_Line, /*count*/ -1, &count));
3034 ASSERT_EQ(-1, count);
3035 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"some text");
3036}
void SetNameExplicitlyEmpty()

◆ TEST_F() [45/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestITextRangeProviderMoveEndpointByWord   
)

Definition at line 2698 of file ax_platform_node_textrangeprovider_win_unittest.cc.

2699 {
2700 Init(BuildTextDocument({"some text", "more text", "even more text"},
2701 /*build_word_boundaries_offsets*/ true));
2702
2703 ComPtr<ITextRangeProvider> text_range_provider;
2704 GetTextRangeProviderFromTextNode(text_range_provider,
2705 GetRootAsAXNode()->children()[1]);
2706 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"more text");
2707
2708 // Moving with zero count does not alter the range.
2709 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(text_range_provider,
2710 TextPatternRangeEndpoint_End, TextUnit_Word,
2711 /*count*/ 0,
2712 /*expected_text*/ L"more text",
2713 /*expected_count*/ 0);
2714
2715 // Moving the start forward and backward.
2717 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Word,
2718 /*count*/ 1,
2719 /*expected_text*/ L"text",
2720 /*expected_count*/ 1);
2722 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Word,
2723 /*count*/ -1,
2724 /*expected_text*/ L"more text",
2725 /*expected_count*/ -1);
2726
2727 // Moving the end backward and forward.
2728 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(text_range_provider,
2729 TextPatternRangeEndpoint_End, TextUnit_Word,
2730 /*count*/ -1,
2731 /*expected_text*/ L"more ",
2732 /*expected_count*/ -1);
2733 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(text_range_provider,
2734 TextPatternRangeEndpoint_End, TextUnit_Word,
2735 /*count*/ 1,
2736 /*expected_text*/ L"more text",
2737 /*expected_count*/ 1);
2738
2739 // Moving the start past the end, then reverting.
2741 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Word,
2742 /*count*/ 3,
2743 /*expected_text*/ L"",
2744 /*expected_count*/ 3);
2746 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Word,
2747 /*count*/ -3,
2748 /*expected_text*/ L"more texteven ",
2749 /*expected_count*/ -3);
2750 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(text_range_provider,
2751 TextPatternRangeEndpoint_End, TextUnit_Word,
2752 /*count*/ -1,
2753 /*expected_text*/ L"more text",
2754 /*expected_count*/ -1);
2755
2756 // Moving the end past the start, then reverting.
2757 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(text_range_provider,
2758 TextPatternRangeEndpoint_End, TextUnit_Word,
2759 /*count*/ -3,
2760 /*expected_text*/ L"",
2761 /*expected_count*/ -3);
2762 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(text_range_provider,
2763 TextPatternRangeEndpoint_End, TextUnit_Word,
2764 /*count*/ 3,
2765 /*expected_text*/ L"textmore text",
2766 /*expected_count*/ 3);
2768 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Word,
2769 /*count*/ 1,
2770 /*expected_text*/ L"more text",
2771 /*expected_count*/ 1);
2772
2773 // Moving the endpoints further than both ends of the document.
2774 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(text_range_provider,
2775 TextPatternRangeEndpoint_End, TextUnit_Word,
2776 /*count*/ 5,
2777 /*expected_text*/ L"more texteven more text",
2778 /*expected_count*/ 3);
2780 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Word,
2781 /*count*/ 6,
2782 /*expected_text*/ L"",
2783 /*expected_count*/ 5);
2785 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Word,
2786 /*count*/ -8,
2787 /*expected_text*/ L"some textmore texteven more text",
2788 /*expected_count*/ -7);
2789 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(text_range_provider,
2790 TextPatternRangeEndpoint_End, TextUnit_Word,
2791 /*count*/ -8,
2792 /*expected_text*/ L"",
2793 /*expected_count*/ -7);
2794}

◆ TEST_F() [46/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestITextRangeProviderMoveFormat   
)

Definition at line 1983 of file ax_platform_node_textrangeprovider_win_unittest.cc.

1984 {
1985 Init(BuildAXTreeForMoveByFormat());
1986 AXNode* root_node = GetRootAsAXNode();
1987
1988 ComPtr<ITextRangeProvider> text_range_provider;
1989 GetTextRangeProviderFromTextNode(text_range_provider, root_node);
1990
1991 // Moving by 0 should have no effect.
1993 text_range_provider, TextUnit_Format,
1994 /*count*/ 0,
1995 /*expected_text*/
1996 L"Text with formatting\nStandalone line with no formatting\nbold "
1997 L"text\nParagraph 1\nParagraph 2\nParagraph 3\nParagraph 4",
1998 /*expected_count*/ 0);
1999
2000 // Move forward.
2001 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Format,
2002 /*count*/ 1,
2003 /*expected_text*/ L"\nStandalone line with no formatting\n",
2004 /*expected_count*/ 1);
2005 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Format,
2006 /*count*/ 2,
2007 /*expected_text*/ L"Paragraph 1",
2008 /*expected_count*/ 2);
2009 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Format,
2010 /*count*/ 1,
2011 /*expected_text*/ L"Paragraph 2\nParagraph 3",
2012 /*expected_count*/ 1);
2013 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Format,
2014 /*count*/ 1,
2015 /*expected_text*/ L"Paragraph 4",
2016 /*expected_count*/ 1);
2017
2018 // Trying to move past the last format should have no effect.
2019 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Format,
2020 /*count*/ 1,
2021 /*expected_text*/ L"Paragraph 4",
2022 /*expected_count*/ 0);
2023
2024 // Move backward.
2025 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Format,
2026 /*count*/ -3,
2027 /*expected_text*/ L"bold text",
2028 /*expected_count*/ -3);
2029 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Format,
2030 /*count*/ -1,
2031 /*expected_text*/ L"\nStandalone line with no formatting\n",
2032 /*expected_count*/ -1);
2033 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Format,
2034 /*count*/ -1,
2035 /*expected_text*/ L"Text with formatting",
2036 /*expected_count*/ -1);
2037
2038 // Moving backward by any number of formats at the start of document
2039 // should have no effect.
2040 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Format,
2041 /*count*/ -1,
2042 /*expected_text*/
2043 L"Text with formatting",
2044 /*expected_count*/ 0);
2045
2046 // Test degenerate range creation at the beginning of the document.
2048 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Format,
2049 /*count*/ -1,
2050 /*expected_text*/ L"",
2051 /*expected_count*/ -1);
2053 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Format,
2054 /*count*/ 1,
2055 /*expected_text*/ L"Text with formatting",
2056 /*expected_count*/ 1);
2057
2058 // Test degenerate range creation at the end of the document.
2059 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Format,
2060 /*count*/ 5,
2061 /*expected_text*/ L"Paragraph 4",
2062 /*expected_count*/ 5);
2064 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Format,
2065 /*count*/ 1,
2066 /*expected_text*/ L"",
2067 /*expected_count*/ 1);
2069 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Format,
2070 /*count*/ -1,
2071 /*expected_text*/ L"Paragraph 4",
2072 /*expected_count*/ -1);
2074 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Format,
2075 /*count*/ 1,
2076 /*expected_text*/ L"",
2077 /*expected_count*/ 1);
2079 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Format,
2080 /*count*/ -1,
2081 /*expected_text*/ L"Paragraph 4",
2082 /*expected_count*/ -1);
2083
2084 // Degenerate range moves.
2085 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Format,
2086 /*count*/ -5,
2087 /*expected_text*/ L"Text with formatting",
2088 /*expected_count*/ -5);
2090 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Format,
2091 /*count*/ -1,
2092 /*expected_text*/ L"",
2093 /*expected_count*/ -1);
2094 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Format,
2095 /*count*/ 3,
2096 /*expected_text*/ L"",
2097 /*expected_count*/ 3);
2098 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Format,
2099 /*count*/ 70,
2100 /*expected_text*/ L"",
2101 /*expected_count*/ 3);
2102
2103 // Trying to move past the last format should have no effect.
2104 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Format,
2105 /*count*/ 70,
2106 /*expected_text*/ L"",
2107 /*expected_count*/ 0);
2108 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Format,
2109 /*count*/ -2,
2110 /*expected_text*/ L"",
2111 /*expected_count*/ -2);
2112}

◆ TEST_F() [47/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestITextRangeProviderMoveLine   
)

Definition at line 2208 of file ax_platform_node_textrangeprovider_win_unittest.cc.

2209 {
2210 Init(BuildAXTreeForMove());
2211 AXNode* root_node = GetRootAsAXNode();
2212
2213 ComPtr<ITextRangeProvider> text_range_provider;
2214 GetTextRangeProviderFromTextNode(text_range_provider, root_node);
2215
2216 // Moving by 0 should have no effect.
2217 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Line, /*count*/ 0,
2218 /*expected_text*/ tree_for_move_full_text.data(),
2219 /*expected_count*/ 0);
2220
2221 // Move forward.
2222 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Line,
2223 /*count*/ 2,
2224 /*expected_text*/ L"Standalone line",
2225 /*expected_count*/ 2);
2226 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Line,
2227 /*count*/ 1,
2228 /*expected_text*/ L"bold text",
2229 /*expected_count*/ 1);
2230 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Line,
2231 /*count*/ 10,
2232 /*expected_text*/ L"Paragraph 2",
2233 /*expected_count*/ 2);
2234
2235 // Trying to move past the last line should have no effect.
2236 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Line,
2237 /*count*/ 1,
2238 /*expected_text*/ L"Paragraph 2",
2239 /*expected_count*/ 0);
2240
2241 // Move backward.
2242 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Line,
2243 /*count*/ -1,
2244 /*expected_text*/ L"Paragraph 1",
2245 /*expected_count*/ -1);
2246 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Line,
2247 /*count*/ -5,
2248 /*expected_text*/ L"First line of text",
2249 /*expected_count*/ -4);
2250
2251 // Moving backward by any number of lines at the start of document
2252 // should have no effect.
2253 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Line,
2254 /*count*/ -20,
2255 /*expected_text*/ L"First line of text",
2256 /*expected_count*/ 0);
2257
2258 // Degenerate range moves.
2259 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(text_range_provider,
2260 TextPatternRangeEndpoint_End, TextUnit_Line,
2261 /*count*/ -1,
2262 /*expected_text*/ L"",
2263 /*expected_count*/ -1);
2264 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Line,
2265 /*count*/ 4,
2266 /*expected_text*/ L"",
2267 /*expected_count*/ 4);
2268 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Line,
2269 /*count*/ 70,
2270 /*expected_text*/ L"",
2271 /*expected_count*/ 2);
2272
2273 // Trying to move past the last line should have no effect.
2274 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Line,
2275 /*count*/ 70,
2276 /*expected_text*/ L"",
2277 /*expected_count*/ 0);
2278 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Line,
2279 /*count*/ -2,
2280 /*expected_text*/ L"",
2281 /*expected_count*/ -2);
2282}

◆ TEST_F() [48/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestITextRangeProviderMoveParagraph   
)

Definition at line 2285 of file ax_platform_node_textrangeprovider_win_unittest.cc.

2286 {
2287 Init(BuildAXTreeForMove());
2288 AXNode* root_node = GetRootAsAXNode();
2289
2290 ComPtr<ITextRangeProvider> text_range_provider;
2291 GetTextRangeProviderFromTextNode(text_range_provider, root_node);
2292
2293 // Moving by 0 should have no effect.
2294 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Paragraph, /*count*/ 0,
2295 /*expected_text*/ tree_for_move_full_text.data(),
2296 /*expected_count*/ 0);
2297
2299 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Paragraph,
2300 /*count*/ -4,
2301 /*expected_text*/ L"First line of text\n",
2302 /*expected_count*/ -4);
2303
2304 // The first line break does not create an empty paragraph because even though
2305 // it is in a block element (i.e. a kGenericContainer) of its own which is a
2306 // line breaking object, it merges with the previous paragraph. This is
2307 // standard UIA behavior which merges any trailing whitespace with the
2308 // previous paragraph.
2310 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Paragraph,
2311 /*count*/ -1,
2312 /*expected_text*/ L"",
2313 /*expected_count*/ -1);
2315 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Paragraph,
2316 /*count*/ 1,
2317 /*expected_text*/ L"First line of text\n",
2318 /*expected_count*/ 1);
2319
2320 //
2321 // Move forward.
2322 //
2323
2324 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Paragraph,
2325 /*count*/ 1,
2326 /*expected_text*/ L"Standalone line\n",
2327 /*expected_count*/ 1);
2328 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Paragraph,
2329 /*count*/ 1,
2330 /*expected_text*/ L"bold text\n",
2331 /*expected_count*/ 1);
2332 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Paragraph,
2333 /*count*/ 1,
2334 /*expected_text*/ L"Paragraph 1\n",
2335 /*expected_count*/ 1);
2336 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Paragraph,
2337 /*count*/ 1,
2338 /*expected_text*/ L"Paragraph 2",
2339 /*expected_count*/ 1);
2340 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Paragraph,
2341 /*count*/ 2,
2342 /*expected_text*/ L"Paragraph 2",
2343 /*expected_count*/ 0);
2344
2345 // Trying to move past the last paragraph should have no effect.
2346 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Paragraph,
2347 /*count*/ 1,
2348 /*expected_text*/ L"Paragraph 2",
2349 /*expected_count*/ 0);
2350
2351 //
2352 // Move backward.
2353 //
2354
2355 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Paragraph,
2356 /*count*/ -1,
2357 /*expected_text*/ L"Paragraph 1\n",
2358 /*expected_count*/ -1);
2359 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Paragraph,
2360 /*count*/ -1,
2361 /*expected_text*/ L"bold text\n",
2362 /*expected_count*/ -1);
2363 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Paragraph,
2364 /*count*/ -1,
2365 /*expected_text*/ L"Standalone line\n",
2366 /*expected_count*/ -1);
2367 // The first line break creates an empty paragraph because it is in a block
2368 // element (i.e. a kGenericContainer) of its own which is a line breaking
2369 // object. It's like having a <br> element wrapped inside a <div>.
2370 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Paragraph,
2371 /*count*/ -1,
2372 /*expected_text*/ L"First line of text\n",
2373 /*expected_count*/ -1);
2374 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Paragraph,
2375 /*count*/ -1,
2376 /*expected_text*/ L"First line of text\n",
2377 /*expected_count*/ 0);
2378
2379 // Moving backward by any number of paragraphs at the start of document
2380 // should have no effect.
2381 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Paragraph,
2382 /*count*/ -1,
2383 /*expected_text*/ L"First line of text\n",
2384 /*expected_count*/ 0);
2385
2386 // Test degenerate range creation at the beginning of the document.
2388 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Paragraph,
2389 /*count*/ -1,
2390 /*expected_text*/ L"",
2391 /*expected_count*/ -1);
2393 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Paragraph,
2394 /*count*/ 1,
2395 /*expected_text*/ L"First line of text\n",
2396 /*expected_count*/ 1);
2397
2398 // Test degenerate range creation at the end of the document.
2399 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Paragraph,
2400 /*count*/ 5,
2401 /*expected_text*/ L"Paragraph 2",
2402 /*expected_count*/ 4);
2404 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Paragraph,
2405 /*count*/ 1,
2406 /*expected_text*/ L"",
2407 /*expected_count*/ 1);
2409 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Paragraph,
2410 /*count*/ -1,
2411 /*expected_text*/ L"Paragraph 2",
2412 /*expected_count*/ -1);
2414 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Paragraph,
2415 /*count*/ 1,
2416 /*expected_text*/ L"",
2417 /*expected_count*/ 1);
2419 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Paragraph,
2420 /*count*/ -1,
2421 /*expected_text*/ L"Paragraph 2",
2422 /*expected_count*/ -1);
2423
2424 //
2425 // Degenerate range moves.
2426 //
2427
2428 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Paragraph,
2429 /*count*/ -6,
2430 /*expected_text*/ L"First line of text\n",
2431 /*expected_count*/ -4);
2433 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Paragraph,
2434 /*count*/ -1,
2435 /*expected_text*/ L"",
2436 /*expected_count*/ -1);
2437 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Paragraph,
2438 /*count*/ 3,
2439 /*expected_text*/ L"",
2440 /*expected_count*/ 3);
2441 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Paragraph,
2442 /*count*/ 70,
2443 /*expected_text*/ L"",
2444 /*expected_count*/ 2);
2445
2446 // Trying to move past the last paragraph should have no effect.
2447 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Paragraph,
2448 /*count*/ 70,
2449 /*expected_text*/ L"",
2450 /*expected_count*/ 0);
2451 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Paragraph,
2452 /*count*/ -2,
2453 /*expected_text*/ L"",
2454 /*expected_count*/ -2);
2455}

◆ TEST_F() [49/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestITextRangeProviderMoveWord   
)

Definition at line 2115 of file ax_platform_node_textrangeprovider_win_unittest.cc.

2116 {
2117 Init(BuildAXTreeForMove());
2118 AXNode* root_node = GetRootAsAXNode();
2119
2120 ComPtr<ITextRangeProvider> text_range_provider;
2121 GetTextRangeProviderFromTextNode(text_range_provider, root_node);
2122
2123 // Moving by 0 should have no effect.
2124 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Word, /*count*/ 0,
2125 /*expected_text*/ tree_for_move_full_text.data(),
2126 /*expected_count*/ 0);
2127
2128 // Move forward.
2129 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Word,
2130 /*count*/ 1,
2131 /*expected_text*/ L"line ",
2132 /*expected_count*/ 1);
2133 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Word,
2134 /*count*/ 2,
2135 /*expected_text*/ L"text",
2136 /*expected_count*/ 2);
2137 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Word,
2138 /*count*/ 2,
2139 /*expected_text*/ L"line",
2140 /*expected_count*/ 2);
2141 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Word,
2142 /*count*/ 3,
2143 /*expected_text*/ L"Paragraph ",
2144 /*expected_count*/ 3);
2145 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Word,
2146 /*count*/ 6,
2147 /*expected_text*/ L"2",
2148 /*expected_count*/ 3);
2149
2150 // Trying to move past the last word should have no effect.
2151 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Word,
2152 /*count*/ 1,
2153 /*expected_text*/ L"2",
2154 /*expected_count*/ 0);
2155
2156 // Move backward.
2157 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Word,
2158 /*count*/ -3,
2159 /*expected_text*/ L"Paragraph ",
2160 /*expected_count*/ -3);
2161 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Word,
2162 /*count*/ -3,
2163 /*expected_text*/ L"line",
2164 /*expected_count*/ -3);
2165 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Word,
2166 /*count*/ -2,
2167 /*expected_text*/ L"text",
2168 /*expected_count*/ -2);
2169 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Word,
2170 /*count*/ -6,
2171 /*expected_text*/ L"First ",
2172 /*expected_count*/ -3);
2173
2174 // Moving backward by any number of words at the start of document
2175 // should have no effect.
2176 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Word,
2177 /*count*/ -20,
2178 /*expected_text*/ L"First ",
2179 /*expected_count*/ 0);
2180
2181 // Degenerate range moves.
2182 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(text_range_provider,
2183 TextPatternRangeEndpoint_End, TextUnit_Word,
2184 /*count*/ -1,
2185 /*expected_text*/ L"",
2186 /*expected_count*/ -1);
2187 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Word,
2188 /*count*/ 4,
2189 /*expected_text*/ L"",
2190 /*expected_count*/ 4);
2191 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Word,
2192 /*count*/ 70,
2193 /*expected_text*/ L"",
2194 /*expected_count*/ 8);
2195
2196 // Trying to move past the last word should have no effect.
2197 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Word,
2198 /*count*/ 70,
2199 /*expected_text*/ L"",
2200 /*expected_count*/ 0);
2201 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Word,
2202 /*count*/ -2,
2203 /*expected_text*/ L"",
2204 /*expected_count*/ -2);
2205}

◆ TEST_F() [50/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestNormalizeTextRangeForceSameAnchorOnDegenerateRange   
)

Definition at line 6291 of file ax_platform_node_textrangeprovider_win_unittest.cc.

6292 {
6293 // ++1 kRootWebArea
6294 // ++++2 kGenericContainer
6295 // ++++++3 kImage
6296 // ++++4 kTextField
6297 // ++++++5 kGenericContainer
6298 // ++++++++6 kStaticText
6299 // ++++++++++7 kInlineTextBox
6300 ui::AXNodeData root_1;
6301 ui::AXNodeData generic_container_2;
6302 ui::AXNodeData line_break_3;
6303 ui::AXNodeData text_field_4;
6304 ui::AXNodeData generic_container_5;
6305 ui::AXNodeData static_text_6;
6306 ui::AXNodeData inline_box_7;
6307
6308 root_1.id = 1;
6309 generic_container_2.id = 2;
6310 line_break_3.id = 3;
6311 text_field_4.id = 4;
6312 generic_container_5.id = 5;
6313 static_text_6.id = 6;
6314 inline_box_7.id = 7;
6315
6317 root_1.child_ids = {generic_container_2.id, text_field_4.id};
6318
6319 generic_container_2.role = ax::mojom::Role::kGenericContainer;
6320 generic_container_2.AddBoolAttribute(
6322 generic_container_2.child_ids = {line_break_3.id};
6323
6324 line_break_3.role = ax::mojom::Role::kLineBreak;
6325
6326 text_field_4.role = ax::mojom::Role::kTextField;
6328 text_field_4.child_ids = {generic_container_5.id};
6329 text_field_4.SetValue("3.14");
6330
6331 generic_container_5.role = ax::mojom::Role::kGenericContainer;
6332 generic_container_5.child_ids = {static_text_6.id};
6333
6334 static_text_6.role = ax::mojom::Role::kStaticText;
6335 static_text_6.child_ids = {inline_box_7.id};
6336 static_text_6.SetName("3.14");
6337
6339 inline_box_7.SetName("3.14");
6340
6342 ui::AXTreeData tree_data;
6344 update.tree_data = tree_data;
6345 update.has_tree_data = true;
6346 update.root_id = root_1.id;
6347 update.nodes.push_back(root_1);
6348 update.nodes.push_back(generic_container_2);
6349 update.nodes.push_back(line_break_3);
6350 update.nodes.push_back(text_field_4);
6351 update.nodes.push_back(generic_container_5);
6352 update.nodes.push_back(static_text_6);
6353 update.nodes.push_back(inline_box_7);
6354
6355 Init(update);
6356 const AXTree* tree = GetTree();
6357
6358 const AXNode* line_break_3_node = tree->GetFromId(line_break_3.id);
6359 const AXNode* inline_box_7_node = tree->GetFromId(inline_box_7.id);
6360
6361 AXPlatformNodeWin* owner = static_cast<AXPlatformNodeWin*>(
6362 AXPlatformNodeFromNode(GetNodeFromTree(tree_data.tree_id, 1)));
6363
6364 // start: TextPosition, anchor_id=3, text_offset=1, annotated_text=/xFFFC<>
6365 // end : TextPosition, anchor_id=7, text_offset=0, annotated_text=<p>i
6366 ComPtr<AXPlatformNodeTextRangeProviderWin> range;
6367 CreateTextRangeProviderWin(
6368 range, owner,
6369 /*start_anchor=*/line_break_3_node, /*start_offset=*/1,
6370 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
6371 /*end_anchor=*/inline_box_7_node, /*end_offset=*/0,
6372 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
6373
6374 auto original_start = GetStart(range.Get())->Clone();
6375 auto original_end = GetEnd(range.Get())->Clone();
6376
6377 AXNodePosition::AXPositionInstance normalized_start =
6378 GetStart(range.Get())->Clone();
6379 AXNodePosition::AXPositionInstance normalized_end =
6380 GetEnd(range.Get())->Clone();
6381 NormalizeTextRange(range.Get(), normalized_start, normalized_end);
6382 // Verify that the original range was not changed by normalization.
6383 ExpectPositionsEqual(original_start, GetStart(range.Get()));
6384 ExpectPositionsEqual(original_end, GetEnd(range.Get()));
6385
6386 EXPECT_EQ(*normalized_start, *normalized_start);
6387
6388 EXPECT_TRUE(normalized_start->AtStartOfAnchor());
6389 EXPECT_TRUE(normalized_end->AtStartOfAnchor());
6390 EXPECT_EQ(7, normalized_start->anchor_id());
6391 EXPECT_EQ(7, normalized_end->anchor_id());
6392}

◆ TEST_F() [51/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
DISABLED_TestValidateStartAndEnd   
)

Definition at line 6395 of file ax_platform_node_textrangeprovider_win_unittest.cc.

6395 {
6396 // This test updates the tree structure to test a specific edge case -
6397 // CreatePositionAtFormatBoundary when text lies at the beginning and end
6398 // of the AX tree.
6399 AXNodeData root_data;
6400 root_data.id = 1;
6402
6403 AXNodeData text_data;
6404 text_data.id = 2;
6406 text_data.SetName("some text");
6407
6408 AXNodeData more_text_data;
6409 more_text_data.id = 3;
6410 more_text_data.role = ax::mojom::Role::kStaticText;
6411 more_text_data.SetName("more text");
6412
6413 root_data.child_ids = {text_data.id, more_text_data.id};
6414
6417 update.root_id = root_data.id;
6418 update.tree_data.tree_id = tree_id;
6419 update.has_tree_data = true;
6420 update.nodes = {root_data, text_data, more_text_data};
6421
6422 Init(update);
6423 const AXTree* tree = GetTree();
6424
6425 const AXNode* root_node = tree->GetFromId(root_data.id);
6426 const AXNode* more_text_node = tree->GetFromId(more_text_data.id);
6427
6428 // Create a position at MaxTextOffset
6429 // Making |owner| AXID:1 so that |TestAXNodeWrapper::BuildAllWrappers|
6430 // will build the entire tree.
6431 AXPlatformNodeWin* owner = static_cast<AXPlatformNodeWin*>(
6432 AXPlatformNodeFromNode(GetNodeFromTree(tree_id, 1)));
6433
6434 // start: TextPosition, anchor_id=1, text_offset=0, annotated_text=<s>ome text
6435 // end : TextPosition, anchor_id=3, text_offset=9, annotated_text=more text<>
6436 ComPtr<AXPlatformNodeTextRangeProviderWin> text_range_provider;
6437 CreateTextRangeProviderWin(
6438 text_range_provider, owner,
6439 /*start_anchor=*/root_node, /*start_offset=*/0,
6440 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
6441 /*end_anchor=*/more_text_node, /*end_offset=*/9,
6442 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
6443
6444 // Since the end of the range is at MaxTextOffset, moving it by 1 character
6445 // should have an expected_count of 0.
6447 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Character,
6448 /*count*/ 1,
6449 /*expected_text*/ L"some textmore text",
6450 /*expected_count*/ 0);
6451
6452 // Now make a change to shorten MaxTextOffset. Ensure that this position is
6453 // invalid, then call SnapToMaxTextOffsetIfBeyond and ensure that it is now
6454 // valid.
6455 more_text_data.SetName("ore tex");
6456 AXTreeUpdate test_update;
6457 test_update.nodes = {more_text_data};
6458 ASSERT_TRUE(GetTree()->Unserialize(test_update));
6459
6461 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Character,
6462 /*count*/ 1,
6463 /*expected_text*/ L"some textore tex",
6464 /*expected_count*/ 0);
6465
6466 // Now modify the tree so that start_ is pointing to a node that has been
6467 // removed from the tree.
6468 text_data.SetNameExplicitlyEmpty();
6469 AXTreeUpdate test_update2;
6470 test_update2.nodes = {text_data};
6471 ASSERT_TRUE(GetTree()->Unserialize(test_update2));
6472
6474 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Character,
6475 /*count*/ 1,
6476 /*expected_text*/ L"re tex",
6477 /*expected_count*/ 1);
6478
6479 // Now adjust a node that's not the final node in the tree to point past
6480 // MaxTextOffset. First move the range endpoints so that they're pointing to
6481 // MaxTextOffset on the first node.
6482 text_data.SetName("some text");
6483 AXTreeUpdate test_update3;
6484 test_update3.nodes = {text_data};
6485 ASSERT_TRUE(GetTree()->Unserialize(test_update3));
6486
6488 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Character,
6489 /*count*/ -10,
6490 /*expected_text*/ L"some textore tex",
6491 /*expected_count*/ -10);
6492
6493 // Ensure that we're at MaxTextOffset on the first node by first
6494 // overshooting a negative move...
6496 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Character,
6497 /*count*/ -8,
6498 /*expected_text*/ L"some tex",
6499 /*expected_count*/ -8);
6500
6501 // ...followed by a positive move
6503 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Character,
6504 /*count*/ 1,
6505 /*expected_text*/ L"some text",
6506 /*expected_count*/ 1);
6507
6508 // Now our range's start_ is pointing to offset 0 on the first node and end_
6509 // is pointing to MaxTextOffset on the first node. Now modify the tree so
6510 // that MaxTextOffset is invalid on the first node and ensure that we can
6511 // still move
6512 text_data.SetName("some tex");
6513 AXTreeUpdate test_update4;
6514 test_update4.nodes = {text_data};
6515 ASSERT_TRUE(GetTree()->Unserialize(test_update4));
6516
6518 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Character,
6519 /*count*/ 1,
6520 /*expected_text*/ L"ome tex",
6521 /*expected_count*/ 1);
6522}

◆ TEST_F() [52/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
ElementNotAvailable   
)

Definition at line 5805 of file ax_platform_node_textrangeprovider_win_unittest.cc.

5805 {
5806 AXNodeData root_ax_node_data;
5807 root_ax_node_data.id = 1;
5808 root_ax_node_data.role = ax::mojom::Role::kRootWebArea;
5809
5810 Init(root_ax_node_data);
5811
5812 ComPtr<IRawElementProviderSimple> raw_element_provider_simple =
5813 QueryInterfaceFromNode<IRawElementProviderSimple>(GetRootAsAXNode());
5814 ASSERT_NE(nullptr, raw_element_provider_simple.Get());
5815
5816 ComPtr<ITextProvider> text_provider;
5817 ASSERT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
5818 UIA_TextPatternId, &text_provider));
5819 ASSERT_NE(nullptr, text_provider.Get());
5820
5821 ComPtr<ITextRangeProvider> text_range_provider;
5822 ASSERT_HRESULT_SUCCEEDED(
5823 text_provider->get_DocumentRange(&text_range_provider));
5824 ASSERT_NE(nullptr, text_range_provider.Get());
5825
5826 // An empty tree.
5827 SetTree(std::make_unique<AXTree>());
5828
5829 BOOL bool_arg = FALSE;
5830 ASSERT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
5831 text_range_provider->ScrollIntoView(bool_arg));
5832}
return FALSE

◆ TEST_F() [53/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
FindTextWithEmbeddedObjectCharacter   
)

Definition at line 5178 of file ax_platform_node_textrangeprovider_win_unittest.cc.

5179 {
5180 // ++1 kRootWebArea
5181 // ++++2 kList
5182 // ++++++3 kListItem
5183 // ++++++++4 kStaticText
5184 // ++++++++++5 kInlineTextBox
5185 // ++++++6 kListItem
5186 // ++++++++7 kStaticText
5187 // ++++++++++8 kInlineTextBox
5188 ui::AXNodeData root_1;
5189 ui::AXNodeData list_2;
5190 ui::AXNodeData list_item_3;
5191 ui::AXNodeData static_text_4;
5192 ui::AXNodeData inline_box_5;
5193 ui::AXNodeData list_item_6;
5194 ui::AXNodeData static_text_7;
5195 ui::AXNodeData inline_box_8;
5196
5197 root_1.id = 1;
5198 list_2.id = 2;
5199 list_item_3.id = 3;
5200 static_text_4.id = 4;
5201 inline_box_5.id = 5;
5202 list_item_6.id = 6;
5203 static_text_7.id = 7;
5204 inline_box_8.id = 8;
5205
5207 root_1.child_ids = {list_2.id};
5208
5210 list_2.child_ids = {list_item_3.id, list_item_6.id};
5211
5212 list_item_3.role = ax::mojom::Role::kListItem;
5213 list_item_3.child_ids = {static_text_4.id};
5214
5215 static_text_4.role = ax::mojom::Role::kStaticText;
5216 static_text_4.SetName("foo");
5217 static_text_4.child_ids = {inline_box_5.id};
5218
5220 inline_box_5.SetName("foo");
5221
5222 list_item_6.role = ax::mojom::Role::kListItem;
5223 list_item_6.child_ids = {static_text_7.id};
5224
5225 static_text_7.role = ax::mojom::Role::kStaticText;
5226 static_text_7.child_ids = {inline_box_8.id};
5227 static_text_7.SetName("bar");
5228
5230 inline_box_8.SetName("bar");
5231
5233 ui::AXTreeData tree_data;
5235 update.tree_data = tree_data;
5236 update.has_tree_data = true;
5237 update.root_id = root_1.id;
5238 update.nodes = {root_1, list_2, list_item_3, static_text_4,
5239 inline_box_5, list_item_6, static_text_7, inline_box_8};
5240
5241 Init(update);
5242
5243 AXNode* root_node = GetRootAsAXNode();
5244 ComPtr<ITextRangeProvider> text_range_provider;
5245 GetTextRangeProviderFromTextNode(text_range_provider, root_node);
5246
5248 Microsoft::WRL::ComPtr<ITextRangeProvider> text_range_provider_found;
5249 EXPECT_HRESULT_SUCCEEDED(text_range_provider->FindText(
5250 find_string.Get(), false, false, &text_range_provider_found));
5251 ASSERT_TRUE(text_range_provider_found.Get());
5252 Microsoft::WRL::ComPtr<AXPlatformNodeTextRangeProviderWin>
5253 text_range_provider_win;
5254 text_range_provider_found->QueryInterface(
5255 IID_PPV_ARGS(&text_range_provider_win));
5256 ASSERT_TRUE(GetStart(text_range_provider_win.Get())->IsTextPosition());
5257 EXPECT_EQ(5, GetStart(text_range_provider_win.Get())->anchor_id());
5258 EXPECT_EQ(1, GetStart(text_range_provider_win.Get())->text_offset());
5259 ASSERT_TRUE(GetEnd(text_range_provider_win.Get())->IsTextPosition());
5260 EXPECT_EQ(8, GetEnd(text_range_provider_win.Get())->anchor_id());
5261 EXPECT_EQ(3, GetEnd(text_range_provider_win.Get())->text_offset());
5262}
static int find_string(const TArray< SkString > &strings, const char ext[])

◆ TEST_F() [54/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestDeleteSubtreeThatIncludesEndpoints   
)

Definition at line 6682 of file ax_platform_node_textrangeprovider_win_unittest.cc.

6683 {
6684 // This test updates the tree structure to ensure that the text range is still
6685 // valid after a subtree that includes the text range is deleted, resulting in
6686 // a change to the range.
6687 //
6688 // ++1 kRootWebArea
6689 // ++++2 kStaticText "one"
6690 // ++++3 kGenericContainer
6691 // ++++++4 kGenericContainer
6692 // ++++++++5 kStaticText " two"
6693 // ++++++6 kGenericContainer
6694 // ++++++++7 kStaticText " three"
6695 AXNodeData root_1;
6696 AXNodeData text_2;
6697 AXNodeData gc_3;
6698 AXNodeData gc_4;
6699 AXNodeData text_5;
6700 AXNodeData gc_6;
6701 AXNodeData text_7;
6702
6703 root_1.id = 1;
6704 text_2.id = 2;
6705 gc_3.id = 3;
6706 gc_4.id = 4;
6707 text_5.id = 5;
6708 gc_6.id = 6;
6709 text_7.id = 7;
6710
6712 root_1.child_ids = {text_2.id, gc_3.id};
6713
6715 text_2.SetName("one");
6716
6718 gc_3.child_ids = {gc_4.id, gc_6.id};
6719
6721 gc_4.child_ids = {text_5.id};
6722
6724 text_5.SetName(" two");
6725
6727 gc_6.child_ids = {text_7.id};
6728
6730 text_7.SetName(" three");
6731
6734 update.root_id = root_1.id;
6735 update.tree_data.tree_id = tree_id;
6736 update.has_tree_data = true;
6737 update.nodes = {root_1, text_2, gc_3, gc_4, text_5, gc_6, text_7};
6738
6739 Init(update);
6740 const AXTree* tree = GetTree();
6741
6742 const AXNode* text_5_node = tree->GetFromId(text_5.id);
6743 const AXNode* text_7_node = tree->GetFromId(text_7.id);
6744
6745 // Making |owner| AXID:1 so that |TestAXNodeWrapper::BuildAllWrappers|
6746 // will build the entire tree.
6747 AXPlatformNodeWin* owner = static_cast<AXPlatformNodeWin*>(
6748 AXPlatformNodeFromNode(GetNodeFromTree(tree_id, 1)));
6749
6750 // Create a range that spans " two three" located on the leaf nodes.
6751
6752 // start: TextPosition, anchor_id=5, text_offset=0
6753 // end : TextPosition, anchor_id=7, text_offset=6
6754 ComPtr<AXPlatformNodeTextRangeProviderWin> range;
6755 CreateTextRangeProviderWin(
6756 range, owner,
6757 /*start_anchor*/ text_5_node, /*start_offset*/ 0,
6758 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
6759 /*end_anchor*/ text_7_node, /*end_offset*/ 6,
6760 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
6761
6762 EXPECT_UIA_TEXTRANGE_EQ(range, /*expected_text*/ L" two three");
6763
6764 // Delete |gc_3|, which will delete the entire subtree where both of our
6765 // endpoints are.
6766 AXTreeUpdate test_update;
6767 root_1.child_ids = {text_2.id};
6768 test_update.nodes = {root_1};
6769 ASSERT_TRUE(GetTree()->Unserialize(test_update));
6770
6771 // The text range should now be a degenerate range positioned at the end of
6772 // root, the parent of |gc_3|, since |gc_3| has been deleted.
6773 EXPECT_EQ(root_1.id, GetStart(range.Get())->anchor_id());
6774 EXPECT_EQ(3, GetStart(range.Get())->text_offset());
6775
6776 EXPECT_EQ(root_1.id, GetEnd(range.Get())->anchor_id());
6777 EXPECT_EQ(3, GetEnd(range.Get())->text_offset());
6778}

◆ TEST_F() [55/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestDeleteTreePositionPreviousSibling   
)

Definition at line 7044 of file ax_platform_node_textrangeprovider_win_unittest.cc.

7045 {
7046 // This test creates a degenerate range with endpoints pointing after the last
7047 // child of the 2 generic container. It then deletes a previous sibling and
7048 // ensures that we don't crash with an out of bounds index that causes null
7049 // child positions to be created.
7050 //
7051 // ++1 kRootWebArea
7052 // ++++2 kGenericContainer
7053 // ++++++3 kHeading
7054 // ++++++++4 kStaticText
7055 // ++++++++++5 kInlineTextBox
7056 // ++++++6 kGenericContainer
7057 // ++++++7 kButton
7058 ui::AXNodeData root_1;
7059 ui::AXNodeData generic_container_2;
7060 ui::AXNodeData heading_3;
7061 ui::AXNodeData static_text_4;
7062 ui::AXNodeData inline_box_5;
7063 ui::AXNodeData generic_container_6;
7064 ui::AXNodeData button_7;
7065
7066 root_1.id = 1;
7067 generic_container_2.id = 2;
7068 heading_3.id = 3;
7069 static_text_4.id = 4;
7070 inline_box_5.id = 5;
7071 generic_container_6.id = 6;
7072 button_7.id = 7;
7073
7075 root_1.child_ids = {generic_container_2.id};
7076
7077 generic_container_2.role = ax::mojom::Role::kGenericContainer;
7078 generic_container_2.child_ids = {heading_3.id, generic_container_6.id,
7079 button_7.id};
7080
7081 heading_3.role = ax::mojom::Role::kHeading;
7082 heading_3.child_ids = {static_text_4.id};
7083
7084 static_text_4.role = ax::mojom::Role::kStaticText;
7085 static_text_4.child_ids = {inline_box_5.id};
7086 static_text_4.SetName("3.14");
7087
7089 inline_box_5.SetName("3.14");
7090
7091 generic_container_6.role = ax::mojom::Role::kGenericContainer;
7092 generic_container_6.AddBoolAttribute(
7094
7095 button_7.role = ax::mojom::Role::kButton;
7096
7098 ui::AXTreeData tree_data;
7100 update.tree_data = tree_data;
7101 update.has_tree_data = true;
7102 update.root_id = root_1.id;
7103 update.nodes = {root_1, generic_container_2, heading_3, static_text_4,
7104 inline_box_5, generic_container_6, button_7};
7105
7106 Init(update);
7107 AXTree* tree = GetTree();
7108
7109 AXNode* root_node = GetRootAsAXNode();
7110 AXNodePosition::AXPositionInstance range_start =
7111 AXNodePosition::CreateTreePosition(tree->GetAXTreeID(),
7112 generic_container_2.id,
7113 /*child_index*/ 3);
7114 AXNodePosition::AXPositionInstance range_end = range_start->Clone();
7115
7116 AXPlatformNodeWin* owner =
7117 static_cast<AXPlatformNodeWin*>(AXPlatformNodeFromNode(root_node));
7118 ComPtr<ITextRangeProvider> text_range_provider =
7119 AXPlatformNodeTextRangeProviderWin::CreateTextRangeProviderForTesting(
7120 owner, std::move(range_start), std::move(range_end));
7121 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"");
7122
7123 generic_container_2.child_ids = {heading_3.id, button_7.id};
7124 AXTreeUpdate test_update;
7125 test_update.nodes = {generic_container_2};
7126 ASSERT_TRUE(tree->Unserialize(test_update));
7127
7128 root_1.child_ids = {};
7129 test_update.nodes = {root_1};
7130 ASSERT_TRUE(tree->Unserialize(test_update));
7131}

◆ TEST_F() [56/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestITextRangeProviderClone   
)

Definition at line 984 of file ax_platform_node_textrangeprovider_win_unittest.cc.

984 {
985 Init(BuildTextDocument({"some text"}));
986
987 ComPtr<ITextRangeProvider> text_range_provider;
988 GetTextRangeProviderFromTextNode(text_range_provider,
989 GetRootAsAXNode()->children()[0]);
990 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"some text");
991
992 ComPtr<ITextRangeProvider> text_range_provider_clone;
993 text_range_provider->Clone(&text_range_provider_clone);
994 CopyOwnerToClone(text_range_provider.Get(), text_range_provider_clone.Get());
995 ComPtr<AXPlatformNodeTextRangeProviderWin> original_range;
996 ComPtr<AXPlatformNodeTextRangeProviderWin> clone_range;
997
998 text_range_provider->QueryInterface(IID_PPV_ARGS(&original_range));
999 text_range_provider_clone->QueryInterface(IID_PPV_ARGS(&clone_range));
1000
1001 EXPECT_EQ(*GetStart(original_range.Get()), *GetStart(clone_range.Get()));
1002 EXPECT_EQ(*GetEnd(original_range.Get()), *GetEnd(clone_range.Get()));
1003 EXPECT_EQ(GetOwner(original_range.Get()), GetOwner(clone_range.Get()));
1004
1005 // Clear original text range provider.
1006 text_range_provider.Reset();
1007 EXPECT_EQ(nullptr, text_range_provider.Get());
1008
1009 // Ensure the clone still works correctly.
1010 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider_clone, L"some text");
1011}

◆ TEST_F() [57/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestITextRangeProviderCompare   
)

Definition at line 3100 of file ax_platform_node_textrangeprovider_win_unittest.cc.

3100 {
3101 Init(BuildTextDocument({"some text", "some text"}));
3102 AXNode* root_node = GetRootAsAXNode();
3103
3104 // Get the textRangeProvider for the document,
3105 // which contains text "some textsome text".
3106 ComPtr<ITextRangeProvider> document_text_range_provider;
3107 GetTextRangeProviderFromTextNode(document_text_range_provider, root_node);
3108
3109 // Get the textRangeProvider for the first text node.
3110 ComPtr<ITextRangeProvider> text_range_provider;
3111 GetTextRangeProviderFromTextNode(text_range_provider,
3112 root_node->children()[0]);
3113
3114 // Get the textRangeProvider for the second text node.
3115 ComPtr<ITextRangeProvider> more_text_range_provider;
3116 GetTextRangeProviderFromTextNode(more_text_range_provider,
3117 root_node->children()[1]);
3118
3119 // Compare text range of the entire document with itself, which should return
3120 // that they are equal.
3121 BOOL result;
3122 EXPECT_HRESULT_SUCCEEDED(document_text_range_provider->Compare(
3123 document_text_range_provider.Get(), &result));
3125
3126 // Compare the text range of the entire document with one of its child, which
3127 // should return that they are not equal.
3128 EXPECT_HRESULT_SUCCEEDED(document_text_range_provider->Compare(
3129 text_range_provider.Get(), &result));
3130 EXPECT_FALSE(result);
3131
3132 // Compare the text range of text_node which contains "some text" with
3133 // text range of more_text_node which also contains "some text". Those two
3134 // text ranges should not equal, because their endpoints are different, even
3135 // though their contents are the same.
3136 EXPECT_HRESULT_SUCCEEDED(
3137 text_range_provider->Compare(more_text_range_provider.Get(), &result));
3138 EXPECT_FALSE(result);
3139}

◆ TEST_F() [58/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestITextRangeProviderCompareEndpoints   
)

Definition at line 1013 of file ax_platform_node_textrangeprovider_win_unittest.cc.

1014 {
1015 Init(BuildTextDocument({"some text", "more text"},
1016 false /* build_word_boundaries_offsets */,
1017 true /* place_text_on_one_line */));
1018
1019 AXNode* root_node = GetRootAsAXNode();
1020
1021 // Get the textRangeProvider for the document,
1022 // which contains text "some textmore text".
1023 ComPtr<ITextRangeProvider> document_text_range_provider;
1024 GetTextRangeProviderFromTextNode(document_text_range_provider, root_node);
1025
1026 // Get the textRangeProvider for "some text".
1027 ComPtr<ITextRangeProvider> text_range_provider;
1028 GetTextRangeProviderFromTextNode(text_range_provider,
1029 root_node->children()[0]);
1030
1031 // Get the textRangeProvider for "more text".
1032 ComPtr<ITextRangeProvider> more_text_range_provider;
1033 GetTextRangeProviderFromTextNode(more_text_range_provider,
1034 root_node->children()[1]);
1035
1036 // Compare the endpoints of the document which contains "some textmore text".
1037 int result;
1038 EXPECT_HRESULT_SUCCEEDED(document_text_range_provider->CompareEndpoints(
1039 TextPatternRangeEndpoint_Start, document_text_range_provider.Get(),
1040 TextPatternRangeEndpoint_Start, &result));
1041 EXPECT_EQ(0, result);
1042
1043 EXPECT_HRESULT_SUCCEEDED(document_text_range_provider->CompareEndpoints(
1044 TextPatternRangeEndpoint_End, document_text_range_provider.Get(),
1045 TextPatternRangeEndpoint_End, &result));
1046 EXPECT_EQ(0, result);
1047
1048 EXPECT_HRESULT_SUCCEEDED(document_text_range_provider->CompareEndpoints(
1049 TextPatternRangeEndpoint_Start, document_text_range_provider.Get(),
1050 TextPatternRangeEndpoint_End, &result));
1051 EXPECT_EQ(-1, result);
1052
1053 EXPECT_HRESULT_SUCCEEDED(document_text_range_provider->CompareEndpoints(
1054 TextPatternRangeEndpoint_End, document_text_range_provider.Get(),
1055 TextPatternRangeEndpoint_Start, &result));
1056 EXPECT_EQ(1, result);
1057
1058 // Compare the endpoints of "some text" and "more text". The position at the
1059 // end of "some text" is logically equivalent to the position at the start of
1060 // "more text".
1061 EXPECT_HRESULT_SUCCEEDED(text_range_provider->CompareEndpoints(
1062 TextPatternRangeEndpoint_Start, more_text_range_provider.Get(),
1063 TextPatternRangeEndpoint_Start, &result));
1064 EXPECT_EQ(-1, result);
1065
1066 EXPECT_HRESULT_SUCCEEDED(text_range_provider->CompareEndpoints(
1067 TextPatternRangeEndpoint_End, more_text_range_provider.Get(),
1068 TextPatternRangeEndpoint_Start, &result));
1069 EXPECT_EQ(0, result);
1070
1071 // Compare the endpoints of "some text" with those of the entire document. The
1072 // position at the start of "some text" is logically equivalent to the
1073 // position at the start of the document.
1074 EXPECT_HRESULT_SUCCEEDED(text_range_provider->CompareEndpoints(
1075 TextPatternRangeEndpoint_Start, document_text_range_provider.Get(),
1076 TextPatternRangeEndpoint_Start, &result));
1077 EXPECT_EQ(0, result);
1078
1079 EXPECT_HRESULT_SUCCEEDED(text_range_provider->CompareEndpoints(
1080 TextPatternRangeEndpoint_End, document_text_range_provider.Get(),
1081 TextPatternRangeEndpoint_End, &result));
1082 EXPECT_EQ(-1, result);
1083
1084 // Compare the endpoints of "more text" with those of the entire document.
1085 EXPECT_HRESULT_SUCCEEDED(more_text_range_provider->CompareEndpoints(
1086 TextPatternRangeEndpoint_Start, document_text_range_provider.Get(),
1087 TextPatternRangeEndpoint_Start, &result));
1088 EXPECT_EQ(1, result);
1089
1090 EXPECT_HRESULT_SUCCEEDED(more_text_range_provider->CompareEndpoints(
1091 TextPatternRangeEndpoint_End, document_text_range_provider.Get(),
1092 TextPatternRangeEndpoint_End, &result));
1093 EXPECT_EQ(0, result);
1094}

◆ TEST_F() [59/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestITextRangeProviderExpandToEnclosingCharacter   
)

Definition at line 1096 of file ax_platform_node_textrangeprovider_win_unittest.cc.

1097 {
1098 ui::AXTreeUpdate update = BuildTextDocument({"some text", "more text"});
1099 Init(update);
1100 AXNode* root_node = GetRootAsAXNode();
1101
1102 ComPtr<ITextRangeProvider> text_range_provider;
1103 GetTextRangeProviderFromTextNode(text_range_provider, root_node);
1104 ASSERT_HRESULT_SUCCEEDED(
1105 text_range_provider->ExpandToEnclosingUnit(TextUnit_Character));
1106 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"s");
1107
1108 int count;
1109 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1110 TextPatternRangeEndpoint_End, TextUnit_Character, /*count*/ 2, &count));
1111 ASSERT_EQ(2, count);
1112 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1113 TextPatternRangeEndpoint_Start, TextUnit_Character, /*count*/ 1, &count));
1114 ASSERT_EQ(1, count);
1115 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"om");
1116
1117 ASSERT_HRESULT_SUCCEEDED(
1118 text_range_provider->ExpandToEnclosingUnit(TextUnit_Character));
1119 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"o");
1120
1121 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1122 TextPatternRangeEndpoint_End, TextUnit_Character, /*count*/ 9, &count));
1123 ASSERT_EQ(9, count);
1124 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1125 TextPatternRangeEndpoint_Start, TextUnit_Character, /*count*/ 8, &count));
1126 ASSERT_EQ(8, count);
1127 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"mo");
1128
1129 ASSERT_HRESULT_SUCCEEDED(
1130 text_range_provider->ExpandToEnclosingUnit(TextUnit_Character));
1131 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"m");
1132
1133 // Move the start and end to the end of the document.
1134 // Expand to enclosing unit should never return a null position.
1135 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1136 TextPatternRangeEndpoint_End, TextUnit_Character, /*count*/ 9, &count));
1137 ASSERT_EQ(8, count);
1138 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1139 TextPatternRangeEndpoint_Start, TextUnit_Character, /*count*/ 9, &count));
1140 ASSERT_EQ(9, count);
1141
1142 ASSERT_HRESULT_SUCCEEDED(
1143 text_range_provider->ExpandToEnclosingUnit(TextUnit_Character));
1144 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"t");
1145
1146 // Move both endpoints to the position before the start of the "more text"
1147 // anchor. Then, force the start to be on the position after the end of
1148 // "some text" by moving one character backward and one forward.
1149 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1150 TextPatternRangeEndpoint_End, TextUnit_Character, /*count*/ -9, &count));
1151 ASSERT_EQ(-9, count);
1152 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1153 TextPatternRangeEndpoint_Start, TextUnit_Character, /*count*/ -1,
1154 &count));
1155 ASSERT_EQ(-1, count);
1156 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1157 TextPatternRangeEndpoint_Start, TextUnit_Character, /*count*/ 1, &count));
1158 ASSERT_EQ(1, count);
1159 ASSERT_HRESULT_SUCCEEDED(
1160 text_range_provider->ExpandToEnclosingUnit(TextUnit_Character));
1161 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"m");
1162
1163 // Check that the enclosing element of the range matches ATs expectations.
1164 ComPtr<IRawElementProviderSimple> more_text_provider =
1165 QueryInterfaceFromNode<IRawElementProviderSimple>(
1166 root_node->children()[1]->children()[0]);
1167 ComPtr<IRawElementProviderSimple> enclosing_element;
1168 ASSERT_HRESULT_SUCCEEDED(
1169 text_range_provider->GetEnclosingElement(&enclosing_element));
1170 EXPECT_EQ(more_text_provider.Get(), enclosing_element.Get());
1171}

◆ TEST_F() [60/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestITextRangeProviderExpandToEnclosingDocument   
)

Definition at line 1643 of file ax_platform_node_textrangeprovider_win_unittest.cc.

1644 {
1645 Init(BuildTextDocument({"some text", "more text", "even more text"}));
1646
1647 AXNode* root_node = GetRootAsAXNode();
1648 AXNode* text_node = root_node->children()[0];
1649 AXNode* more_text_node = root_node->children()[1];
1650 AXNode* even_more_text_node = root_node->children()[2];
1651
1652 // Run the test twice, one for TextUnit_Document and once for TextUnit_Page,
1653 // since they should have identical behavior.
1654 const TextUnit textunit_types[] = {TextUnit_Document, TextUnit_Page};
1655 ComPtr<ITextRangeProvider> text_range_provider;
1656
1657 for (auto& textunit : textunit_types) {
1658 GetTextRangeProviderFromTextNode(text_range_provider, text_node);
1659 ASSERT_HRESULT_SUCCEEDED(
1660 text_range_provider->ExpandToEnclosingUnit(textunit));
1661 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider,
1662 L"some textmore texteven more text");
1663
1664 GetTextRangeProviderFromTextNode(text_range_provider, more_text_node);
1665 ASSERT_HRESULT_SUCCEEDED(
1666 text_range_provider->ExpandToEnclosingUnit(textunit));
1667 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider,
1668 L"some textmore texteven more text");
1669
1670 GetTextRangeProviderFromTextNode(text_range_provider, even_more_text_node);
1671 ASSERT_HRESULT_SUCCEEDED(
1672 text_range_provider->ExpandToEnclosingUnit(textunit));
1673 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider,
1674 L"some textmore texteven more text");
1675 }
1676}

◆ TEST_F() [61/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestITextRangeProviderExpandToEnclosingLine   
)

Definition at line 1222 of file ax_platform_node_textrangeprovider_win_unittest.cc.

1223 {
1224 Init(BuildTextDocument({"line #1", "maybe line #1?", "not line #1"}));
1225
1226 ComPtr<ITextRangeProvider> text_range_provider;
1227 GetTextRangeProviderFromTextNode(text_range_provider,
1228 GetRootAsAXNode()->children()[0]);
1229 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"line #1");
1230
1231 // Start endpoint is already on a line's start boundary.
1232 int count;
1233 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1234 TextPatternRangeEndpoint_End, TextUnit_Character, /*count*/ -11, &count));
1235 ASSERT_EQ(-7, count);
1236 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"");
1237
1238 ASSERT_HRESULT_SUCCEEDED(
1239 text_range_provider->ExpandToEnclosingUnit(TextUnit_Line));
1240 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"line #1");
1241
1242 // Start endpoint is between a line's start and end boundaries.
1243 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1244 TextPatternRangeEndpoint_Start, TextUnit_Character, /*count*/ 13,
1245 &count));
1246 ASSERT_EQ(13, count);
1247 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"");
1248
1249 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1250 TextPatternRangeEndpoint_End, TextUnit_Character, /*count*/ 4, &count));
1251 ASSERT_EQ(4, count);
1252 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"line");
1253
1254 ASSERT_HRESULT_SUCCEEDED(
1255 text_range_provider->ExpandToEnclosingUnit(TextUnit_Line));
1256 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"maybe line #1?");
1257
1258 // Start endpoint is on a line's end boundary.
1259 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1260 TextPatternRangeEndpoint_Start, TextUnit_Character, /*count*/ 29,
1261 &count));
1262 ASSERT_EQ(25, count);
1263 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"");
1264
1265 ASSERT_HRESULT_SUCCEEDED(
1266 text_range_provider->ExpandToEnclosingUnit(TextUnit_Line));
1267 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"not line #1");
1268}

◆ TEST_F() [62/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestITextRangeProviderExpandToEnclosingWord   
)

Definition at line 1173 of file ax_platform_node_textrangeprovider_win_unittest.cc.

1174 {
1175 Init(BuildTextDocument({"some text", "definitely not text"},
1176 /*build_word_boundaries_offsets*/ true));
1177
1178 ComPtr<ITextRangeProvider> text_range_provider;
1179 GetTextRangeProviderFromTextNode(text_range_provider,
1180 GetRootAsAXNode()->children()[1]);
1181 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"definitely not text");
1182
1183 // Start endpoint is already on a word's start boundary.
1184 ASSERT_HRESULT_SUCCEEDED(
1185 text_range_provider->ExpandToEnclosingUnit(TextUnit_Word));
1186 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"definitely ");
1187
1188 // Start endpoint is between a word's start and end boundaries.
1189 int count;
1190 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1191 TextPatternRangeEndpoint_Start, TextUnit_Character, /*count*/ -2,
1192 &count));
1193 ASSERT_EQ(-2, count);
1194 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"xtdefinitely ");
1195
1196 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1197 TextPatternRangeEndpoint_End, TextUnit_Character, /*count*/ 4, &count));
1198 ASSERT_EQ(4, count);
1199 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"xtdefinitely not ");
1200
1201 ASSERT_HRESULT_SUCCEEDED(
1202 text_range_provider->ExpandToEnclosingUnit(TextUnit_Word));
1203 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"text");
1204
1205 // Start endpoint is on a word's end boundary.
1206 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1207 TextPatternRangeEndpoint_Start, TextUnit_Character, /*count*/ 18,
1208 &count));
1209 ASSERT_EQ(18, count);
1210 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"");
1211
1212 ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
1213 TextPatternRangeEndpoint_End, TextUnit_Character, /*count*/ 1, &count));
1214 ASSERT_EQ(1, count);
1215 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L" ");
1216
1217 ASSERT_HRESULT_SUCCEEDED(
1218 text_range_provider->ExpandToEnclosingUnit(TextUnit_Word));
1219 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"not ");
1220}

◆ TEST_F() [63/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestITextRangeProviderFindAttribute   
)

Definition at line 5305 of file ax_platform_node_textrangeprovider_win_unittest.cc.

5306 {
5307 // document - visible
5308 // [empty]
5309 //
5310 // Search forward, look for IsHidden=true.
5311 // Expected: nullptr
5312 // Search forward, look for IsHidden=false.
5313 // Expected: ""
5314 // Note: returns "" rather than nullptr here because document root web area by
5315 // default set to visible. So the text range represents document matches
5316 // our searching criteria. And we return a degenerate range.
5317 //
5318 // Search backward, look for IsHidden=true.
5319 // Expected: nullptr
5320 // Search backward, look for IsHidden=false.
5321 // Expected: ""
5322 // Note: returns "" rather than nullptr here because document root web area by
5323 // default set to visible. So the text range represents document matches
5324 // our searching criteria. And we return a degenerate range.
5325 {
5326 ui::AXNodeData root_data;
5327 root_data.id = 1;
5329
5331 update.tree_data.tree_id = ui::AXTreeID::CreateNewAXTreeID();
5332 update.has_tree_data = true;
5333 update.root_id = root_data.id;
5334 update.nodes = {root_data};
5335
5336 Init(update);
5337
5338 bool is_search_backward;
5339 VARIANT is_hidden_attr_val;
5340 V_VT(&is_hidden_attr_val) = VT_BOOL;
5341 ComPtr<ITextRangeProvider> matched_range_provider;
5342 ComPtr<ITextRangeProvider> document_range_provider;
5343 GetTextRangeProviderFromTextNode(document_range_provider,
5344 GetRootAsAXNode());
5345
5346 // Search forward, look for IsHidden=true.
5347 // Expected: nullptr
5348 V_BOOL(&is_hidden_attr_val) = VARIANT_TRUE;
5349 is_search_backward = false;
5350 document_range_provider->FindAttribute(
5351 UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward,
5352 &matched_range_provider);
5353 ASSERT_EQ(nullptr, matched_range_provider.Get());
5354
5355 // Search forward, look for IsHidden=false.
5356 // Expected: ""
5357 // Note: returns "" rather than nullptr here because document root web area
5358 // by default set to visible. So the text range represents document
5359 // matches our searching criteria. And we return a degenerate range.
5360 V_BOOL(&is_hidden_attr_val) = VARIANT_FALSE;
5361 is_search_backward = false;
5362 document_range_provider->FindAttribute(
5363 UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward,
5364 &matched_range_provider);
5365 ASSERT_NE(nullptr, matched_range_provider.Get());
5366 CopyOwnerToClone(document_range_provider.Get(),
5367 matched_range_provider.Get());
5368 EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"");
5369 matched_range_provider.Reset();
5370
5371 // Search backward, look for IsHidden=true.
5372 // Expected: nullptr
5373 V_BOOL(&is_hidden_attr_val) = VARIANT_TRUE;
5374 is_search_backward = true;
5375 document_range_provider->FindAttribute(
5376 UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward,
5377 &matched_range_provider);
5378 ASSERT_EQ(nullptr, matched_range_provider.Get());
5379
5380 // Search backward, look for IsHidden=false.
5381 // Expected: ""
5382 // Note: returns "" rather than nullptr here because document root web area
5383 // by default set to visible. So the text range represents document
5384 // matches our searching criteria. And we return a degenerate range.
5385 V_BOOL(&is_hidden_attr_val) = VARIANT_FALSE;
5386 is_search_backward = true;
5387 document_range_provider->FindAttribute(
5388 UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward,
5389 &matched_range_provider);
5390 ASSERT_NE(nullptr, matched_range_provider.Get());
5391 CopyOwnerToClone(document_range_provider.Get(),
5392 matched_range_provider.Get());
5393 EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"");
5394 }
5395
5396 // document - visible
5397 // text1 - invisible
5398 //
5399 // Search forward, look for IsHidden=true.
5400 // Expected: "text1"
5401 // Search forward, look for IsHidden=false.
5402 // Expected: nullptr
5403 // Search backward, look for IsHidden=true.
5404 // Expected: "text1"
5405 // Search backward, look for IsHidden=false.
5406 // Expected: nullptr
5407 {
5408 ui::AXNodeData text_data1;
5409 text_data1.id = 2;
5412 text_data1.SetName("text1");
5413
5414 ui::AXNodeData root_data;
5415 root_data.id = 1;
5417 root_data.child_ids = {2};
5418
5420 update.tree_data.tree_id = ui::AXTreeID::CreateNewAXTreeID();
5421 update.has_tree_data = true;
5422 update.root_id = root_data.id;
5423 update.nodes = {root_data, text_data1};
5424
5425 Init(update);
5426
5427 bool is_search_backward;
5428 VARIANT is_hidden_attr_val;
5429 V_VT(&is_hidden_attr_val) = VT_BOOL;
5430 ComPtr<ITextRangeProvider> matched_range_provider;
5431 ComPtr<ITextRangeProvider> document_range_provider;
5432 GetTextRangeProviderFromTextNode(document_range_provider,
5433 GetRootAsAXNode());
5434
5435 // Search forward, look for IsHidden=true.
5436 // Expected: "text1"
5437 V_BOOL(&is_hidden_attr_val) = VARIANT_TRUE;
5438 is_search_backward = false;
5439 document_range_provider->FindAttribute(
5440 UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward,
5441 &matched_range_provider);
5442 ASSERT_NE(nullptr, matched_range_provider.Get());
5443 CopyOwnerToClone(document_range_provider.Get(),
5444 matched_range_provider.Get());
5445 EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text1");
5446 matched_range_provider.Reset();
5447
5448 // Search forward, look for IsHidden=false.
5449 // Expected: nullptr
5450 V_BOOL(&is_hidden_attr_val) = VARIANT_FALSE;
5451 is_search_backward = false;
5452 document_range_provider->FindAttribute(
5453 UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward,
5454 &matched_range_provider);
5455 ASSERT_EQ(nullptr, matched_range_provider.Get());
5456
5457 // Search backward, look for IsHidden=true.
5458 // Expected: "text1"
5459 V_BOOL(&is_hidden_attr_val) = VARIANT_TRUE;
5460 is_search_backward = true;
5461 document_range_provider->FindAttribute(
5462 UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward,
5463 &matched_range_provider);
5464 ASSERT_NE(nullptr, matched_range_provider.Get());
5465 CopyOwnerToClone(document_range_provider.Get(),
5466 matched_range_provider.Get());
5467 EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text1");
5468 matched_range_provider.Reset();
5469
5470 // Search backward, look for IsHidden=false.
5471 // Expected: nullptr
5472 V_BOOL(&is_hidden_attr_val) = VARIANT_FALSE;
5473 is_search_backward = true;
5474 document_range_provider->FindAttribute(
5475 UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward,
5476 &matched_range_provider);
5477 ASSERT_EQ(nullptr, matched_range_provider.Get());
5478 }
5479
5480 // document - visible
5481 // text1 - visible
5482 // text2 - visible
5483 //
5484 // Search forward, look for IsHidden=true.
5485 // Expected: nullptr
5486 // Search forward, look for IsHidden=false.
5487 // Expected: "text1text2"
5488 // Search backward, look for IsHidden=true.
5489 // Expected: nullptr
5490 // Search backward, look for IsHidden=false.
5491 // Expected: "text1text2"
5492 {
5493 ui::AXNodeData text_data1;
5494 text_data1.id = 2;
5496 text_data1.SetName("text1");
5497
5498 ui::AXNodeData text_data2;
5499 text_data2.id = 3;
5501 text_data2.SetName("text2");
5502
5503 ui::AXNodeData root_data;
5504 root_data.id = 1;
5506 root_data.child_ids = {2, 3};
5507
5509 update.tree_data.tree_id = ui::AXTreeID::CreateNewAXTreeID();
5510 update.has_tree_data = true;
5511 update.root_id = root_data.id;
5512 update.nodes = {root_data, text_data1, text_data2};
5513
5514 Init(update);
5515
5516 bool is_search_backward;
5517 VARIANT is_hidden_attr_val;
5518 V_VT(&is_hidden_attr_val) = VT_BOOL;
5519 ComPtr<ITextRangeProvider> matched_range_provider;
5520 ComPtr<ITextRangeProvider> document_range_provider;
5521 GetTextRangeProviderFromTextNode(document_range_provider,
5522 GetRootAsAXNode());
5523
5524 // Search forward, look for IsHidden=true.
5525 // Expected: nullptr
5526 V_BOOL(&is_hidden_attr_val) = VARIANT_TRUE;
5527 is_search_backward = false;
5528 document_range_provider->FindAttribute(
5529 UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward,
5530 &matched_range_provider);
5531 ASSERT_EQ(nullptr, matched_range_provider.Get());
5532
5533 // Search forward, look for IsHidden=false.
5534 // Expected: "text1text2"
5535 V_BOOL(&is_hidden_attr_val) = VARIANT_FALSE;
5536 is_search_backward = false;
5537 document_range_provider->FindAttribute(
5538 UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward,
5539 &matched_range_provider);
5540 ASSERT_NE(nullptr, matched_range_provider.Get());
5541 CopyOwnerToClone(document_range_provider.Get(),
5542 matched_range_provider.Get());
5543 EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text1text2");
5544 matched_range_provider.Reset();
5545
5546 // Search backward, look for IsHidden=true.
5547 // Expected: nullptr
5548 V_BOOL(&is_hidden_attr_val) = VARIANT_TRUE;
5549 is_search_backward = true;
5550 document_range_provider->FindAttribute(
5551 UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward,
5552 &matched_range_provider);
5553 ASSERT_EQ(nullptr, matched_range_provider.Get());
5554
5555 // Search backward, look for IsHidden=false.
5556 // Expected: "text1text2"
5557 V_BOOL(&is_hidden_attr_val) = VARIANT_FALSE;
5558 is_search_backward = true;
5559 document_range_provider->FindAttribute(
5560 UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward,
5561 &matched_range_provider);
5562 ASSERT_NE(nullptr, matched_range_provider.Get());
5563 CopyOwnerToClone(document_range_provider.Get(),
5564 matched_range_provider.Get());
5565 EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text1text2");
5566 }
5567
5568 // document - visible
5569 // text1 - visible
5570 // text2 - invisible
5571 // text3 - invisible
5572 // text4 - visible
5573 // text5 - invisible
5574 //
5575 // Search forward, look for IsHidden=true.
5576 // Expected: "text2text3"
5577 // Search forward, look for IsHidden=false.
5578 // Expected: "text1"
5579 // Search backward, look for IsHidden=true.
5580 // Expected: "text5"
5581 // Search backward, look for IsHidden=false.
5582 // Expected: "text4"
5583 {
5584 ui::AXNodeData text_data1;
5585 text_data1.id = 2;
5587 text_data1.SetName("text1");
5588
5589 ui::AXNodeData text_data2;
5590 text_data2.id = 3;
5593 text_data2.SetName("text2");
5594
5595 ui::AXNodeData text_data3;
5596 text_data3.id = 4;
5599 text_data3.SetName("text3");
5600
5601 ui::AXNodeData text_data4;
5602 text_data4.id = 5;
5604 text_data4.SetName("text4");
5605
5606 ui::AXNodeData text_data5;
5607 text_data5.id = 6;
5610 text_data5.SetName("text5");
5611
5612 ui::AXNodeData root_data;
5613 root_data.id = 1;
5615 root_data.child_ids = {2, 3, 4, 5, 6};
5616
5618 update.tree_data.tree_id = ui::AXTreeID::CreateNewAXTreeID();
5619 update.has_tree_data = true;
5620 update.root_id = root_data.id;
5621 update.nodes = {root_data, text_data1, text_data2,
5622 text_data3, text_data4, text_data5};
5623
5624 Init(update);
5625
5626 bool is_search_backward;
5627 VARIANT is_hidden_attr_val;
5628 V_VT(&is_hidden_attr_val) = VT_BOOL;
5629 ComPtr<ITextRangeProvider> matched_range_provider;
5630 ComPtr<ITextRangeProvider> document_range_provider;
5631 GetTextRangeProviderFromTextNode(document_range_provider,
5632 GetRootAsAXNode());
5633
5634 // Search forward, look for IsHidden=true.
5635 // Expected: "text2text3"
5636 V_BOOL(&is_hidden_attr_val) = VARIANT_TRUE;
5637 is_search_backward = false;
5638 document_range_provider->FindAttribute(
5639 UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward,
5640 &matched_range_provider);
5641 ASSERT_NE(nullptr, matched_range_provider.Get());
5642 CopyOwnerToClone(document_range_provider.Get(),
5643 matched_range_provider.Get());
5644 EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text2text3");
5645 matched_range_provider.Reset();
5646
5647 // Search forward, look for IsHidden=false.
5648 // Expected: "text1"
5649 V_BOOL(&is_hidden_attr_val) = VARIANT_FALSE;
5650 is_search_backward = false;
5651 document_range_provider->FindAttribute(
5652 UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward,
5653 &matched_range_provider);
5654 ASSERT_NE(nullptr, matched_range_provider.Get());
5655 CopyOwnerToClone(document_range_provider.Get(),
5656 matched_range_provider.Get());
5657 EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text1");
5658 matched_range_provider.Reset();
5659
5660 // Search backward, look for IsHidden=true.
5661 // Expected: "text5"
5662 V_BOOL(&is_hidden_attr_val) = VARIANT_TRUE;
5663 is_search_backward = true;
5664 document_range_provider->FindAttribute(
5665 UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward,
5666 &matched_range_provider);
5667 ASSERT_NE(nullptr, matched_range_provider.Get());
5668 CopyOwnerToClone(document_range_provider.Get(),
5669 matched_range_provider.Get());
5670 EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text5");
5671 matched_range_provider.Reset();
5672
5673 // Search backward, look for IsHidden=false.
5674 // Expected: "text4"
5675 V_BOOL(&is_hidden_attr_val) = VARIANT_FALSE;
5676 is_search_backward = true;
5677 document_range_provider->FindAttribute(
5678 UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward,
5679 &matched_range_provider);
5680 ASSERT_NE(nullptr, matched_range_provider.Get());
5681 CopyOwnerToClone(document_range_provider.Get(),
5682 matched_range_provider.Get());
5683 EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text4");
5684 }
5685
5686 // document - visible
5687 // text1 - visible
5688 // text2 - invisible
5689 // text3 - invisible
5690 // text4 - invisible
5691 // text5 - visible
5692 //
5693 // Search forward, look for IsHidden=true.
5694 // Expected: "text2text3text4"
5695 // Search forward, look for IsHidden=false.
5696 // Expected: "text1"
5697 // Search backward, look for IsHidden=true.
5698 // Expected: "text2text3text4"
5699 // Search backward, look for IsHidden=false.
5700 // Expected: "text5"
5701 {
5702 ui::AXNodeData text_data1;
5703 text_data1.id = 2;
5705 text_data1.SetName("text1");
5706
5707 ui::AXNodeData text_data2;
5708 text_data2.id = 3;
5711 text_data2.SetName("text2");
5712
5713 ui::AXNodeData text_data3;
5714 text_data3.id = 4;
5717 text_data3.SetName("text3");
5718
5719 ui::AXNodeData text_data4;
5720 text_data4.id = 5;
5723 text_data4.SetName("text4");
5724
5725 ui::AXNodeData text_data5;
5726 text_data5.id = 6;
5728 text_data5.SetName("text5");
5729
5730 ui::AXNodeData root_data;
5731 root_data.id = 1;
5733 root_data.child_ids = {2, 3, 4, 5, 6};
5734
5736 update.tree_data.tree_id = ui::AXTreeID::CreateNewAXTreeID();
5737 update.has_tree_data = true;
5738 update.root_id = root_data.id;
5739 update.nodes = {root_data, text_data1, text_data2,
5740 text_data3, text_data4, text_data5};
5741
5742 Init(update);
5743
5744 bool is_search_backward;
5745 VARIANT is_hidden_attr_val;
5746 V_VT(&is_hidden_attr_val) = VT_BOOL;
5747 ComPtr<ITextRangeProvider> matched_range_provider;
5748 ComPtr<ITextRangeProvider> document_range_provider;
5749 GetTextRangeProviderFromTextNode(document_range_provider,
5750 GetRootAsAXNode());
5751
5752 // Search forward, look for IsHidden=true.
5753 // Expected: "text2text3text4"
5754 V_BOOL(&is_hidden_attr_val) = VARIANT_TRUE;
5755 is_search_backward = false;
5756 document_range_provider->FindAttribute(
5757 UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward,
5758 &matched_range_provider);
5759 ASSERT_NE(nullptr, matched_range_provider.Get());
5760 CopyOwnerToClone(document_range_provider.Get(),
5761 matched_range_provider.Get());
5762 EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text2text3text4");
5763 matched_range_provider.Reset();
5764
5765 // Search forward, look for IsHidden=false.
5766 // Expected: "text1"
5767 V_BOOL(&is_hidden_attr_val) = VARIANT_FALSE;
5768 is_search_backward = false;
5769 document_range_provider->FindAttribute(
5770 UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward,
5771 &matched_range_provider);
5772 ASSERT_NE(nullptr, matched_range_provider.Get());
5773 CopyOwnerToClone(document_range_provider.Get(),
5774 matched_range_provider.Get());
5775 EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text1");
5776 matched_range_provider.Reset();
5777
5778 // Search backward, look for IsHidden=true.
5779 // Expected: "text2text3text4"
5780 V_BOOL(&is_hidden_attr_val) = VARIANT_TRUE;
5781 is_search_backward = true;
5782 document_range_provider->FindAttribute(
5783 UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward,
5784 &matched_range_provider);
5785 ASSERT_NE(nullptr, matched_range_provider.Get());
5786 CopyOwnerToClone(document_range_provider.Get(),
5787 matched_range_provider.Get());
5788 EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text2text3text4");
5789 matched_range_provider.Reset();
5790
5791 // Search backward, look for IsHidden=false.
5792 // Expected: "text5"
5793 V_BOOL(&is_hidden_attr_val) = VARIANT_FALSE;
5794 is_search_backward = true;
5795 document_range_provider->FindAttribute(
5796 UIA_IsHiddenAttributeId, is_hidden_attr_val, is_search_backward,
5797 &matched_range_provider);
5798 ASSERT_NE(nullptr, matched_range_provider.Get());
5799 CopyOwnerToClone(document_range_provider.Get(),
5800 matched_range_provider.Get());
5801 EXPECT_UIA_TEXTRANGE_EQ(matched_range_provider, L"text5");
5802 }
5803}

◆ TEST_F() [64/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestITextRangeProviderFindText   
)

Definition at line 5110 of file ax_platform_node_textrangeprovider_win_unittest.cc.

5110 {
5111 // Initialize the ICU data from the icudtl.dat file, if it exists.
5112 wchar_t buffer[MAX_PATH];
5113 GetModuleFileName(nullptr, buffer, MAX_PATH);
5114 std::filesystem::path exec_path(buffer);
5115 exec_path.remove_filename();
5116 exec_path.append("icudtl.dat");
5117 const std::string icudtl_path = exec_path.string();
5118 if (std::filesystem::exists(icudtl_path)) {
5119 fml::icu::InitializeICU(icudtl_path);
5120 }
5121
5122 // \xC3\xA9 are the UTF8 bytes for codepoint 0xE9 - accented lowercase e.
5123 Init(BuildTextDocument({"some text", "more text", "resum\xC3\xA9"},
5124 false /* build_word_boundaries_offsets */,
5125 true /* place_text_on_one_line */));
5126
5127 AXNode* root_node = GetRootAsAXNode();
5128 AXPlatformNodeWin* owner =
5129 static_cast<AXPlatformNodeWin*>(AXPlatformNodeFromNode(root_node));
5130 ASSERT_NE(owner, nullptr);
5131 ComPtr<ITextRangeProvider> range;
5132
5133 // Test Leaf kStaticText search.
5134 GetTextRangeProviderFromTextNode(range, root_node->children()[0]);
5135 EXPECT_UIA_FIND_TEXT(range, L"some text", false, owner);
5136 EXPECT_UIA_FIND_TEXT(range, L"SoMe TeXt", true, owner);
5137 GetTextRangeProviderFromTextNode(range, root_node->children()[1]);
5138 EXPECT_UIA_FIND_TEXT(range, L"more", false, owner);
5139 EXPECT_UIA_FIND_TEXT(range, L"MoRe", true, owner);
5140
5141 // Test searching for leaf content from ancestor.
5142 GetTextRangeProviderFromTextNode(range, root_node);
5143 EXPECT_UIA_FIND_TEXT(range, L"some text", false, owner);
5144 EXPECT_UIA_FIND_TEXT(range, L"SoMe TeXt", true, owner);
5145 EXPECT_UIA_FIND_TEXT(range, L"more text", false, owner);
5146 EXPECT_UIA_FIND_TEXT(range, L"MoRe TeXt", true, owner);
5147 EXPECT_UIA_FIND_TEXT(range, L"more", false, owner);
5148 // Accented lowercase e.
5149 EXPECT_UIA_FIND_TEXT(range, L"resum\xE9", false, owner);
5150 // Accented uppercase +e.
5151 EXPECT_UIA_FIND_TEXT(range, L"resum\xC9", true, owner);
5152 EXPECT_UIA_FIND_TEXT(range, L"resume", true, owner);
5153 EXPECT_UIA_FIND_TEXT(range, L"resumE", true, owner);
5154 // Test finding text that crosses a node boundary.
5155 EXPECT_UIA_FIND_TEXT(range, L"textmore", false, owner);
5156 // Test no match.
5157 EXPECT_UIA_FIND_TEXT_NO_MATCH(range, L"no match", false, owner);
5158 EXPECT_UIA_FIND_TEXT_NO_MATCH(range, L"resume", false, owner);
5159
5160 // Test if range returned is in expected anchor node.
5161 GetTextRangeProviderFromTextNode(range, root_node->children()[1]);
5163 Microsoft::WRL::ComPtr<ITextRangeProvider> text_range_provider_found;
5164 EXPECT_HRESULT_SUCCEEDED(range->FindText(find_string.Get(), false, false,
5165 &text_range_provider_found));
5166 Microsoft::WRL::ComPtr<AXPlatformNodeTextRangeProviderWin>
5167 text_range_provider_win;
5168 text_range_provider_found->QueryInterface(
5169 IID_PPV_ARGS(&text_range_provider_win));
5170 ASSERT_TRUE(GetStart(text_range_provider_win.Get())->IsTextPosition());
5171 EXPECT_EQ(5, GetStart(text_range_provider_win.Get())->anchor_id());
5172 EXPECT_EQ(0, GetStart(text_range_provider_win.Get())->text_offset());
5173 ASSERT_TRUE(GetEnd(text_range_provider_win.Get())->IsTextPosition());
5174 EXPECT_EQ(5, GetEnd(text_range_provider_win.Get())->anchor_id());
5175 EXPECT_EQ(9, GetEnd(text_range_provider_win.Get())->text_offset());
5176}
#define EXPECT_UIA_FIND_TEXT(text_range_provider, search_term, ignore_case, owner)
#define EXPECT_UIA_FIND_TEXT_NO_MATCH(text_range_provider, search_term, ignore_case, owner)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
void InitializeICU(const std::string &icu_data_path)
Definition: icu_util.cc:102
#define MAX_PATH

◆ TEST_F() [65/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestITextRangeProviderFindTextBackwards   
)

Definition at line 5264 of file ax_platform_node_textrangeprovider_win_unittest.cc.

5265 {
5266 Init(BuildTextDocument({"text", "some", "text"},
5267 false /* build_word_boundaries_offsets */,
5268 true /* place_text_on_one_line */));
5269 AXNode* root_node = GetRootAsAXNode();
5270
5271 ComPtr<ITextRangeProvider> root_range_provider;
5272 GetTextRangeProviderFromTextNode(root_range_provider, root_node);
5273 ComPtr<ITextRangeProvider> text_node1_range;
5274 GetTextRangeProviderFromTextNode(text_node1_range, root_node->children()[0]);
5275 ComPtr<ITextRangeProvider> text_node3_range;
5276 GetTextRangeProviderFromTextNode(text_node3_range, root_node->children()[2]);
5277
5278 ComPtr<ITextRangeProvider> text_range_provider_found;
5280 BOOL range_equal;
5281
5282 // Forward search finds the text_node1.
5283 EXPECT_HRESULT_SUCCEEDED(root_range_provider->FindText(
5284 find_string.Get(), false, false, &text_range_provider_found));
5285 CopyOwnerToClone(root_range_provider.Get(), text_range_provider_found.Get());
5286 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider_found, find_string.Get());
5287
5288 range_equal = false;
5289 EXPECT_HRESULT_SUCCEEDED(
5290 text_range_provider_found->Compare(text_node1_range.Get(), &range_equal));
5291 EXPECT_TRUE(range_equal);
5292
5293 // Backwards search finds the text_node3.
5294 EXPECT_HRESULT_SUCCEEDED(root_range_provider->FindText(
5295 find_string.Get(), true, false, &text_range_provider_found));
5296 CopyOwnerToClone(root_range_provider.Get(), text_range_provider_found.Get());
5297 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider_found, find_string.Get());
5298
5299 range_equal = false;
5300 EXPECT_HRESULT_SUCCEEDED(
5301 text_range_provider_found->Compare(text_node3_range.Get(), &range_equal));
5302 EXPECT_TRUE(range_equal);
5303}

◆ TEST_F() [66/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestITextRangeProviderGetAttributeValueNotSupported   
)

Definition at line 4733 of file ax_platform_node_textrangeprovider_win_unittest.cc.

4734 {
4735 ui::AXNodeData root_data;
4736 root_data.id = 1;
4738
4739 ui::AXNodeData text_data_first;
4740 text_data_first.id = 2;
4741 text_data_first.role = ax::mojom::Role::kStaticText;
4742 text_data_first.SetName("first");
4743 root_data.child_ids.push_back(text_data_first.id);
4744
4745 ui::AXNodeData text_data_second;
4746 text_data_second.id = 3;
4747 text_data_second.role = ax::mojom::Role::kStaticText;
4748 text_data_second.SetName("second");
4749 root_data.child_ids.push_back(text_data_second.id);
4750
4752 ui::AXTreeData tree_data;
4754 update.tree_data = tree_data;
4755 update.has_tree_data = true;
4756 update.root_id = root_data.id;
4757 update.nodes.push_back(root_data);
4758 update.nodes.push_back(text_data_first);
4759 update.nodes.push_back(text_data_second);
4760
4761 Init(update);
4762
4763 ComPtr<ITextRangeProvider> document_range_provider;
4764 GetTextRangeProviderFromTextNode(document_range_provider, GetRootAsAXNode());
4765
4766 EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED(document_range_provider,
4767 UIA_AfterParagraphSpacingAttributeId);
4768 EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED(document_range_provider,
4769 UIA_AnimationStyleAttributeId);
4770 EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED(document_range_provider,
4771 UIA_BeforeParagraphSpacingAttributeId);
4772 EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED(document_range_provider,
4773 UIA_CapStyleAttributeId);
4774 EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED(document_range_provider,
4775 UIA_CaretBidiModeAttributeId);
4776 EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED(document_range_provider,
4777 UIA_CaretPositionAttributeId);
4778 EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED(document_range_provider,
4779 UIA_IndentationFirstLineAttributeId);
4780 EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED(document_range_provider,
4781 UIA_IndentationLeadingAttributeId);
4782 EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED(document_range_provider,
4783 UIA_IndentationTrailingAttributeId);
4784 EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED(document_range_provider,
4785 UIA_IsActiveAttributeId);
4786 EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED(document_range_provider,
4787 UIA_LineSpacingAttributeId);
4788 EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED(document_range_provider,
4789 UIA_LinkAttributeId);
4790 EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED(document_range_provider,
4791 UIA_MarginBottomAttributeId);
4792 EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED(document_range_provider,
4793 UIA_MarginLeadingAttributeId);
4794 EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED(document_range_provider,
4795 UIA_MarginTopAttributeId);
4796 EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED(document_range_provider,
4797 UIA_MarginTrailingAttributeId);
4798 EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED(document_range_provider,
4799 UIA_OutlineStylesAttributeId);
4800 EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED(document_range_provider,
4801 UIA_OverlineColorAttributeId);
4802 EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED(document_range_provider,
4803 UIA_SelectionActiveEndAttributeId);
4804 EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED(document_range_provider,
4805 UIA_StrikethroughColorAttributeId);
4806 EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED(document_range_provider,
4807 UIA_TabsAttributeId);
4808 EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED(document_range_provider,
4809 UIA_UnderlineColorAttributeId);
4810}
#define EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED(provider, attribute)

◆ TEST_F() [67/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestITextRangeProviderGetAttributeValueWithAncestorTextPosition   
)

Definition at line 4812 of file ax_platform_node_textrangeprovider_win_unittest.cc.

4813 {
4814 ui::AXTreeUpdate initial_state;
4816 initial_state.tree_data.tree_id = tree_id;
4817 initial_state.has_tree_data = true;
4818 initial_state.root_id = 1;
4819 initial_state.nodes.resize(5);
4820 initial_state.nodes[0].id = 1;
4821 initial_state.nodes[0].child_ids = {2};
4822 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
4823 initial_state.nodes[1].id = 2;
4824 initial_state.nodes[1].child_ids = {3};
4825 initial_state.nodes[1].role = ax::mojom::Role::kGenericContainer;
4826 initial_state.nodes[2].id = 3;
4827 initial_state.nodes[2].child_ids = {4, 5};
4828 initial_state.nodes[2].role = ax::mojom::Role::kGenericContainer;
4829 initial_state.nodes[3].id = 4;
4830 initial_state.nodes[3].role = ax::mojom::Role::kStaticText;
4831 initial_state.nodes[3].SetName("some text");
4832 initial_state.nodes[3].AddIntAttribute(
4834 initial_state.nodes[4].id = 5;
4835 initial_state.nodes[4].role = ax::mojom::Role::kStaticText;
4836 initial_state.nodes[4].SetName("more text");
4837 initial_state.nodes[4].AddIntAttribute(
4839
4840 Init(initial_state);
4841 const AXTree* tree = GetTree();
4842 const AXNode* some_text_node = tree->GetFromId(4);
4843 const AXNode* more_text_node = tree->GetFromId(5);
4844
4845 // Making |owner| AXID:2 so that |TestAXNodeWrapper::BuildAllWrappers|
4846 // will build the entire subtree, and not only AXID:3 for example.
4847 AXPlatformNodeWin* owner = static_cast<AXPlatformNodeWin*>(
4848 AXPlatformNodeFromNode(GetNodeFromTree(tree_id, 2)));
4849
4850 // start: TextPosition, anchor_id=4, text_offset=0, annotated_text=<s>ome text
4851 // end : TextPosition, anchor_id=5, text_offset=8,
4852 // annotated_text=more tex<t>
4853 ComPtr<AXPlatformNodeTextRangeProviderWin> text_range_provider_win;
4854 CreateTextRangeProviderWin(
4855 text_range_provider_win, owner,
4856 /*start_anchor=*/some_text_node, /*start_offset=*/0,
4857 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
4858 /*end_anchor=*/more_text_node, /*end_offset=*/8,
4859 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
4860
4861 ASSERT_TRUE(GetStart(text_range_provider_win.Get())->IsTextPosition());
4862 ASSERT_EQ(4, GetStart(text_range_provider_win.Get())->anchor_id());
4863 ASSERT_EQ(0, GetStart(text_range_provider_win.Get())->text_offset());
4864 ASSERT_TRUE(GetEnd(text_range_provider_win.Get())->IsTextPosition());
4865 ASSERT_EQ(5, GetEnd(text_range_provider_win.Get())->anchor_id());
4866 ASSERT_EQ(8, GetEnd(text_range_provider_win.Get())->text_offset());
4867
4868 base::win::ScopedVariant expected_variant;
4869 // SkColor is ARGB, COLORREF is 0BGR
4870 expected_variant.Set(static_cast<int32_t>(0x00EFBEADU));
4871 EXPECT_UIA_TEXTATTRIBUTE_EQ(text_range_provider_win,
4872 UIA_BackgroundColorAttributeId, expected_variant);
4873}

◆ TEST_F() [68/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestITextRangeProviderGetEnclosingElement   
)

Definition at line 3220 of file ax_platform_node_textrangeprovider_win_unittest.cc.

3221 {
3222 // Set up ax tree with the following structure:
3223 //
3224 // root
3225 // |
3226 // paragraph______________________________________________
3227 // | | | | |
3228 // static_text link link search input pdf_highlight
3229 // | | | | |
3230 // text_node static_text ul text_node static_text
3231 // | | |
3232 // text_node li text_node
3233 // |
3234 // static_text
3235 // |
3236 // text_node
3237
3238 ui::AXNodeData root_data;
3239 root_data.id = 1;
3241
3242 ui::AXNodeData paragraph_data;
3243 paragraph_data.id = 2;
3244 paragraph_data.role = ax::mojom::Role::kParagraph;
3245 root_data.child_ids.push_back(paragraph_data.id);
3246
3247 ui::AXNodeData static_text_data1;
3248 static_text_data1.id = 3;
3249 static_text_data1.role = ax::mojom::Role::kStaticText;
3250 paragraph_data.child_ids.push_back(static_text_data1.id);
3251
3252 ui::AXNodeData inline_text_data1;
3253 inline_text_data1.id = 4;
3254 inline_text_data1.role = ax::mojom::Role::kInlineTextBox;
3255 static_text_data1.child_ids.push_back(inline_text_data1.id);
3256
3257 ui::AXNodeData link_data;
3258 link_data.id = 5;
3259 link_data.role = ax::mojom::Role::kLink;
3260 paragraph_data.child_ids.push_back(link_data.id);
3261
3262 ui::AXNodeData static_text_data2;
3263 static_text_data2.id = 6;
3264 static_text_data2.role = ax::mojom::Role::kStaticText;
3265 link_data.child_ids.push_back(static_text_data2.id);
3266
3267 ui::AXNodeData inline_text_data2;
3268 inline_text_data2.id = 7;
3269 inline_text_data2.role = ax::mojom::Role::kInlineTextBox;
3270 static_text_data2.child_ids.push_back(inline_text_data2.id);
3271
3272 ui::AXNodeData link_data2;
3273 link_data2.id = 8;
3274 link_data2.role = ax::mojom::Role::kLink;
3275 paragraph_data.child_ids.push_back(link_data2.id);
3276
3277 ui::AXNodeData list_data;
3278 list_data.id = 9;
3279 list_data.role = ax::mojom::Role::kList;
3280 link_data2.child_ids.push_back(list_data.id);
3281
3282 ui::AXNodeData list_item_data;
3283 list_item_data.id = 10;
3284 list_item_data.role = ax::mojom::Role::kListItem;
3285 list_data.child_ids.push_back(list_item_data.id);
3286
3287 ui::AXNodeData static_text_data3;
3288 static_text_data3.id = 11;
3289 static_text_data3.role = ax::mojom::Role::kStaticText;
3290 list_item_data.child_ids.push_back(static_text_data3.id);
3291
3292 ui::AXNodeData inline_text_data3;
3293 inline_text_data3.id = 12;
3294 inline_text_data3.role = ax::mojom::Role::kInlineTextBox;
3295 static_text_data3.child_ids.push_back(inline_text_data3.id);
3296
3297 ui::AXNodeData search_box;
3298 search_box.id = 13;
3299 search_box.role = ax::mojom::Role::kSearchBox;
3303 "search");
3304 paragraph_data.child_ids.push_back(search_box.id);
3305
3306 ui::AXNodeData search_text;
3307 search_text.id = 14;
3308 search_text.role = ax::mojom::Role::kStaticText;
3310 search_text.SetName("placeholder");
3311 search_box.child_ids.push_back(search_text.id);
3312
3313 ui::AXNodeData pdf_highlight_data;
3314 pdf_highlight_data.id = 15;
3316 paragraph_data.child_ids.push_back(pdf_highlight_data.id);
3317
3318 ui::AXNodeData static_text_data4;
3319 static_text_data4.id = 16;
3320 static_text_data4.role = ax::mojom::Role::kStaticText;
3321 pdf_highlight_data.child_ids.push_back(static_text_data4.id);
3322
3323 ui::AXNodeData inline_text_data4;
3324 inline_text_data4.id = 17;
3325 inline_text_data4.role = ax::mojom::Role::kInlineTextBox;
3326 static_text_data4.child_ids.push_back(inline_text_data4.id);
3327
3329 ui::AXTreeData tree_data;
3331 update.tree_data = tree_data;
3332 update.has_tree_data = true;
3333 update.root_id = root_data.id;
3334 update.nodes = {root_data, paragraph_data, static_text_data1,
3335 inline_text_data1, link_data, static_text_data2,
3336 inline_text_data2, link_data2, list_data,
3337 list_item_data, static_text_data3, inline_text_data3,
3338 search_box, search_text, pdf_highlight_data,
3339 static_text_data4, inline_text_data4};
3340 Init(update);
3341
3342 // Set up variables from the tree for testing.
3343 AXNode* paragraph_node = GetRootAsAXNode()->children()[0];
3344 AXNode* static_text_node1 = paragraph_node->children()[0];
3345 AXNode* link_node = paragraph_node->children()[1];
3346 AXNode* inline_text_node1 = static_text_node1->children()[0];
3347 AXNode* static_text_node2 = link_node->children()[0];
3348 AXNode* inline_text_node2 = static_text_node2->children()[0];
3349 AXNode* link_node2 = paragraph_node->children()[2];
3350 AXNode* list_node = link_node2->children()[0];
3351 AXNode* list_item_node = list_node->children()[0];
3352 AXNode* static_text_node3 = list_item_node->children()[0];
3353 AXNode* inline_text_node3 = static_text_node3->children()[0];
3354 AXNode* search_box_node = paragraph_node->children()[3];
3355 AXNode* search_text_node = search_box_node->children()[0];
3356 AXNode* pdf_highlight_node = paragraph_node->children()[4];
3357 AXNode* static_text_node4 = pdf_highlight_node->children()[0];
3358 AXNode* inline_text_node4 = static_text_node4->children()[0];
3359 AXPlatformNodeWin* owner =
3360 static_cast<AXPlatformNodeWin*>(AXPlatformNodeFromNode(paragraph_node));
3361 ASSERT_NE(owner, nullptr);
3362
3363 ComPtr<IRawElementProviderSimple> link_node_raw =
3364 QueryInterfaceFromNode<IRawElementProviderSimple>(link_node);
3365 ComPtr<IRawElementProviderSimple> static_text_node_raw1 =
3366 QueryInterfaceFromNode<IRawElementProviderSimple>(static_text_node1);
3367 ComPtr<IRawElementProviderSimple> static_text_node_raw2 =
3368 QueryInterfaceFromNode<IRawElementProviderSimple>(static_text_node2);
3369 ComPtr<IRawElementProviderSimple> static_text_node_raw3 =
3370 QueryInterfaceFromNode<IRawElementProviderSimple>(static_text_node3);
3371 ComPtr<IRawElementProviderSimple> inline_text_node_raw1 =
3372 QueryInterfaceFromNode<IRawElementProviderSimple>(inline_text_node1);
3373 ComPtr<IRawElementProviderSimple> inline_text_node_raw2 =
3374 QueryInterfaceFromNode<IRawElementProviderSimple>(inline_text_node2);
3375 ComPtr<IRawElementProviderSimple> inline_text_node_raw3 =
3376 QueryInterfaceFromNode<IRawElementProviderSimple>(inline_text_node3);
3377 ComPtr<IRawElementProviderSimple> search_box_node_raw =
3378 QueryInterfaceFromNode<IRawElementProviderSimple>(search_box_node);
3379 ComPtr<IRawElementProviderSimple> search_text_node_raw =
3380 QueryInterfaceFromNode<IRawElementProviderSimple>(search_text_node);
3381 ComPtr<IRawElementProviderSimple> pdf_highlight_node_raw =
3382 QueryInterfaceFromNode<IRawElementProviderSimple>(pdf_highlight_node);
3383 ComPtr<IRawElementProviderSimple> inline_text_node_raw4 =
3384 QueryInterfaceFromNode<IRawElementProviderSimple>(inline_text_node4);
3385
3386 // Test GetEnclosingElement for the two leaves text nodes. The enclosing
3387 // element of the first one should be its static text parent (because inline
3388 // text boxes shouldn't be exposed) and the enclosing element for the text
3389 // node that is grandchild of the link node should return the link node.
3390 // The text node in the link node with a complex subtree should behave
3391 // normally and return the static text parent.
3392 ComPtr<ITextProvider> text_provider;
3393 EXPECT_HRESULT_SUCCEEDED(inline_text_node_raw1->GetPatternProvider(
3394 UIA_TextPatternId, &text_provider));
3395
3396 ComPtr<ITextRangeProvider> text_range_provider;
3397 EXPECT_HRESULT_SUCCEEDED(
3398 text_provider->get_DocumentRange(&text_range_provider));
3399 SetOwner(owner, text_range_provider.Get());
3400
3401 ComPtr<IRawElementProviderSimple> enclosing_element;
3402 EXPECT_HRESULT_SUCCEEDED(
3403 text_range_provider->GetEnclosingElement(&enclosing_element));
3404 EXPECT_EQ(inline_text_node_raw1.Get(), enclosing_element.Get());
3405
3406 EXPECT_HRESULT_SUCCEEDED(inline_text_node_raw2->GetPatternProvider(
3407 UIA_TextPatternId, &text_provider));
3408
3409 EXPECT_HRESULT_SUCCEEDED(
3410 text_provider->get_DocumentRange(&text_range_provider));
3411 SetOwner(owner, text_range_provider.Get());
3412
3413 EXPECT_HRESULT_SUCCEEDED(
3414 text_range_provider->GetEnclosingElement(&enclosing_element));
3415 EXPECT_EQ(link_node_raw.Get(), enclosing_element.Get());
3416
3417 EXPECT_HRESULT_SUCCEEDED(inline_text_node_raw3->GetPatternProvider(
3418 UIA_TextPatternId, &text_provider));
3419
3420 EXPECT_HRESULT_SUCCEEDED(
3421 text_provider->get_DocumentRange(&text_range_provider));
3422 SetOwner(owner, text_range_provider.Get());
3423
3424 EXPECT_HRESULT_SUCCEEDED(
3425 text_range_provider->GetEnclosingElement(&enclosing_element));
3426 EXPECT_EQ(inline_text_node_raw3.Get(), enclosing_element.Get());
3427
3428 // The enclosing element of a text range in the search text should give the
3429 // search box
3430 EXPECT_HRESULT_SUCCEEDED(search_text_node_raw->GetPatternProvider(
3431 UIA_TextPatternId, &text_provider));
3432
3433 EXPECT_HRESULT_SUCCEEDED(
3434 text_provider->get_DocumentRange(&text_range_provider));
3435 SetOwner(owner, text_range_provider.Get());
3436
3437 EXPECT_HRESULT_SUCCEEDED(
3438 text_range_provider->ExpandToEnclosingUnit(TextUnit_Character));
3439
3440 EXPECT_HRESULT_SUCCEEDED(
3441 text_range_provider->GetEnclosingElement(&enclosing_element));
3442 EXPECT_EQ(search_box_node_raw.Get(), enclosing_element.Get());
3443
3444 // The enclosing element for the text node that is grandchild of the
3445 // pdf_highlight node should return the pdf_highlight node.
3446 EXPECT_HRESULT_SUCCEEDED(inline_text_node_raw4->GetPatternProvider(
3447 UIA_TextPatternId, &text_provider));
3448
3449 EXPECT_HRESULT_SUCCEEDED(
3450 text_provider->get_DocumentRange(&text_range_provider));
3451 SetOwner(owner, text_range_provider.Get());
3452
3453 EXPECT_HRESULT_SUCCEEDED(
3454 text_range_provider->GetEnclosingElement(&enclosing_element));
3455 EXPECT_EQ(pdf_highlight_node_raw.Get(), enclosing_element.Get());
3456}

◆ TEST_F() [69/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestITextRangeProviderGetEnclosingElementRichButton   
)

Definition at line 3458 of file ax_platform_node_textrangeprovider_win_unittest.cc.

3459 {
3460 // Set up ax tree with the following structure:
3461 //
3462 // root
3463 // ++button_1
3464 // ++++static_text_1
3465 // ++++++inline_text_1
3466 // ++button_2
3467 // ++++heading
3468 // ++++++statix_text_2
3469 // ++++++++inline_text_2
3470
3472 ui::AXNodeData button_1;
3473 ui::AXNodeData static_text_1;
3474 ui::AXNodeData inline_text_1;
3475 ui::AXNodeData button_2;
3476 ui::AXNodeData heading;
3477 ui::AXNodeData static_text_2;
3478 ui::AXNodeData inline_text_2;
3479
3480 root.id = 1;
3481 button_1.id = 2;
3482 static_text_1.id = 3;
3483 inline_text_1.id = 4;
3484 button_2.id = 5;
3485 heading.id = 6;
3486 static_text_2.id = 7;
3487 inline_text_2.id = 8;
3488
3490 root.child_ids = {button_1.id, button_2.id};
3491
3492 button_1.role = ax::mojom::Role::kButton;
3493 button_1.child_ids.push_back(static_text_1.id);
3494
3495 static_text_1.role = ax::mojom::Role::kStaticText;
3496 static_text_1.child_ids.push_back(inline_text_1.id);
3497
3498 inline_text_1.role = ax::mojom::Role::kInlineTextBox;
3499
3500 button_2.role = ax::mojom::Role::kButton;
3501 button_2.child_ids.push_back(heading.id);
3502
3504 heading.child_ids.push_back(static_text_2.id);
3505
3506 static_text_2.role = ax::mojom::Role::kStaticText;
3507 static_text_2.child_ids.push_back(inline_text_2.id);
3508
3509 inline_text_2.role = ax::mojom::Role::kInlineTextBox;
3510
3512 ui::AXTreeData tree_data;
3514 update.tree_data = tree_data;
3515 update.has_tree_data = true;
3516 update.root_id = root.id;
3517 update.nodes = {root, button_1, static_text_1, inline_text_1,
3518 button_2, heading, static_text_2, inline_text_2};
3519 Init(update);
3520
3521 // Set up variables from the tree for testing.
3522 AXNode* button_1_node = GetRootAsAXNode()->children()[0];
3523 AXNode* static_text_1_node = button_1_node->children()[0];
3524 AXNode* inline_text_1_node = static_text_1_node->children()[0];
3525 AXNode* button_2_node = GetRootAsAXNode()->children()[1];
3526 AXNode* heading_node = button_2_node->children()[0];
3527 AXNode* static_text_2_node = heading_node->children()[0];
3528 AXNode* inline_text_2_node = static_text_2_node->children()[0];
3529 AXPlatformNodeWin* owner =
3530 static_cast<AXPlatformNodeWin*>(AXPlatformNodeFromNode(button_1_node));
3531 ASSERT_NE(owner, nullptr);
3532
3533 ComPtr<IRawElementProviderSimple> button_1_node_raw =
3534 QueryInterfaceFromNode<IRawElementProviderSimple>(button_1_node);
3535 ComPtr<IRawElementProviderSimple> inline_text_1_node_raw =
3536 QueryInterfaceFromNode<IRawElementProviderSimple>(inline_text_1_node);
3537
3538 ComPtr<IRawElementProviderSimple> button_2_node_raw =
3539 QueryInterfaceFromNode<IRawElementProviderSimple>(button_2_node);
3540 ComPtr<IRawElementProviderSimple> static_text_2_node_raw =
3541 QueryInterfaceFromNode<IRawElementProviderSimple>(static_text_2_node);
3542 ComPtr<IRawElementProviderSimple> inline_text_2_node_raw =
3543 QueryInterfaceFromNode<IRawElementProviderSimple>(inline_text_2_node);
3544
3545 // 1. The first button should hide its children since it contains a single
3546 // text node. Thus, calling GetEnclosingElement on a descendant inline text
3547 // box should return the button itself.
3548 ComPtr<ITextProvider> text_provider;
3549 EXPECT_HRESULT_SUCCEEDED(inline_text_1_node_raw->GetPatternProvider(
3550 UIA_TextPatternId, &text_provider));
3551
3552 ComPtr<ITextRangeProvider> text_range_provider;
3553 EXPECT_HRESULT_SUCCEEDED(
3554 text_provider->get_DocumentRange(&text_range_provider));
3555 SetOwner(owner, text_range_provider.Get());
3556
3557 ComPtr<IRawElementProviderSimple> enclosing_element;
3558 EXPECT_HRESULT_SUCCEEDED(
3559 text_range_provider->GetEnclosingElement(&enclosing_element));
3560 EXPECT_EQ(button_1_node_raw.Get(), enclosing_element.Get());
3561
3562 // 2. The second button shouldn't hide its children since it doesn't contain a
3563 // single text node (it contains a heading node). Thus, calling
3564 // GetEnclosingElement on a descendant inline text box should return the
3565 // parent node.
3566 EXPECT_HRESULT_SUCCEEDED(inline_text_2_node_raw->GetPatternProvider(
3567 UIA_TextPatternId, &text_provider));
3568
3569 EXPECT_HRESULT_SUCCEEDED(
3570 text_provider->get_DocumentRange(&text_range_provider));
3571 SetOwner(owner, text_range_provider.Get());
3572
3573 EXPECT_HRESULT_SUCCEEDED(
3574 text_range_provider->GetEnclosingElement(&enclosing_element));
3575 EXPECT_EQ(button_2_node_raw.Get(), enclosing_element.Get());
3576}

◆ TEST_F() [70/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestITextRangeProviderGetText   
)

Definition at line 1845 of file ax_platform_node_textrangeprovider_win_unittest.cc.

1845 {
1846 Init(BuildTextDocument({"some text", "more text"}));
1847
1848 AXNode* root_node = GetRootAsAXNode();
1849 AXNode* text_node = root_node->children()[0];
1850
1851 ComPtr<ITextRangeProvider> text_range_provider;
1852 GetTextRangeProviderFromTextNode(text_range_provider, text_node);
1853
1854 base::win::ScopedBstr text_content;
1855 EXPECT_HRESULT_SUCCEEDED(
1856 text_range_provider->GetText(-1, text_content.Receive()));
1857 EXPECT_STREQ(text_content.Get(), L"some text");
1858 text_content.Reset();
1859
1860 EXPECT_HRESULT_SUCCEEDED(
1861 text_range_provider->GetText(4, text_content.Receive()));
1862 EXPECT_STREQ(text_content.Get(), L"some");
1863 text_content.Reset();
1864
1865 EXPECT_HRESULT_SUCCEEDED(
1866 text_range_provider->GetText(0, text_content.Receive()));
1867 EXPECT_STREQ(text_content.Get(), L"");
1868 text_content.Reset();
1869
1870 EXPECT_HRESULT_SUCCEEDED(
1871 text_range_provider->GetText(9, text_content.Receive()));
1872 EXPECT_STREQ(text_content.Get(), L"some text");
1873 text_content.Reset();
1874
1875 EXPECT_HRESULT_SUCCEEDED(
1876 text_range_provider->GetText(10, text_content.Receive()));
1877 EXPECT_STREQ(text_content.Get(), L"some text");
1878 text_content.Reset();
1879
1880 EXPECT_HRESULT_FAILED(text_range_provider->GetText(-1, nullptr));
1881
1882 EXPECT_HRESULT_FAILED(
1883 text_range_provider->GetText(-2, text_content.Receive()));
1884 text_content.Reset();
1885
1886 ComPtr<ITextRangeProvider> document_textrange;
1887 GetTextRangeProviderFromTextNode(document_textrange, root_node);
1888
1889 EXPECT_HRESULT_SUCCEEDED(
1890 document_textrange->GetText(-1, text_content.Receive()));
1891 EXPECT_STREQ(text_content.Get(), L"some textmore text");
1892 text_content.Reset();
1893}

◆ TEST_F() [71/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestITextRangeProviderMove   
)

Definition at line 2510 of file ax_platform_node_textrangeprovider_win_unittest.cc.

2510 {
2511 Init(BuildAXTreeForMove());
2512 AXNode* root_node = GetRootAsAXNode();
2513
2514 ComPtr<ITextRangeProvider> text_range_provider;
2515 GetTextRangeProviderFromTextNode(text_range_provider, root_node);
2516
2517 // TODO(https://crbug.com/928948): test intermixed unit types
2518}

◆ TEST_F() [72/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestITextRangeProviderMoveCharacter   
)

Definition at line 1895 of file ax_platform_node_textrangeprovider_win_unittest.cc.

1896 {
1897 Init(BuildAXTreeForMove());
1898 AXNode* root_node = GetRootAsAXNode();
1899
1900 ComPtr<ITextRangeProvider> text_range_provider;
1901 GetTextRangeProviderFromTextNode(text_range_provider, root_node);
1902
1903 // Moving by 0 should have no effect.
1904 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Character, /*count*/ 0,
1905 /*expected_text*/
1906 L"First line of text\nStandalone line\n"
1907 L"bold textParagraph 1Paragraph 2",
1908 /*expected_count*/ 0);
1909
1910 // Move forward.
1911 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Character,
1912 /*count*/ 1,
1913 /*expected_text*/ L"i",
1914 /*expected_count*/ 1);
1915 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Character,
1916 /*count*/ 18,
1917 /*expected_text*/ L"S",
1918 /*expected_count*/ 18);
1919 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Character,
1920 /*count*/ 16,
1921 /*expected_text*/ L"b",
1922 /*expected_count*/ 16);
1923 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Character,
1924 /*count*/ 60,
1925 /*expected_text*/ L"2",
1926 /*expected_count*/ 30);
1927
1928 // Trying to move past the last character should have no effect.
1929 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Character,
1930 /*count*/ 1,
1931 /*expected_text*/ L"2",
1932 /*expected_count*/ 0);
1933
1934 // Move backward.
1935 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Character,
1936 /*count*/ -2,
1937 /*expected_text*/ L"h",
1938 /*expected_count*/ -2);
1939 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Character,
1940 /*count*/ -9,
1941 /*expected_text*/ L"1",
1942 /*expected_count*/ -9);
1943 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Character,
1944 /*count*/ -60,
1945 /*expected_text*/ L"F",
1946 /*expected_count*/ -54);
1947
1948 // Moving backward by any number of characters at the start of document
1949 // should have no effect.
1950 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Character,
1951 /*count*/ -1,
1952 /*expected_text*/
1953 L"F",
1954 /*expected_count*/ 0);
1955
1956 // Degenerate range moves.
1958 text_range_provider, TextPatternRangeEndpoint_End, TextUnit_Character,
1959 /*count*/ -1,
1960 /*expected_text*/ L"",
1961 /*expected_count*/ -1);
1962 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Character,
1963 /*count*/ 4,
1964 /*expected_text*/ L"",
1965 /*expected_count*/ 4);
1966 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Character,
1967 /*count*/ 70,
1968 /*expected_text*/ L"",
1969 /*expected_count*/ 62);
1970
1971 // Trying to move past the last character should have no effect.
1972 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Character,
1973 /*count*/ 70,
1974 /*expected_text*/ L"",
1975 /*expected_count*/ 0);
1976 EXPECT_UIA_MOVE(text_range_provider, TextUnit_Character,
1977 /*count*/ -2,
1978 /*expected_text*/ L"",
1979 /*expected_count*/ -2);
1980}

◆ TEST_F() [73/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestITextRangeProviderMoveEndpointByDocument   
)

Definition at line 2520 of file ax_platform_node_textrangeprovider_win_unittest.cc.

2521 {
2522 Init(BuildTextDocument({"some text", "more text", "even more text"}));
2523 AXNode* text_node = GetRootAsAXNode()->children()[1];
2524
2525 // Run the test twice, one for TextUnit_Document and once for TextUnit_Page,
2526 // since they should have identical behavior.
2527 const TextUnit textunit_types[] = {TextUnit_Document, TextUnit_Page};
2528 ComPtr<ITextRangeProvider> text_range_provider;
2529
2530 for (auto& textunit : textunit_types) {
2531 GetTextRangeProviderFromTextNode(text_range_provider, text_node);
2532
2533 // Verify MoveEndpointByUnit with zero count has no effect
2534 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(text_range_provider,
2535 TextPatternRangeEndpoint_End, textunit,
2536 /*count*/ 0,
2537 /*expected_text*/ L"more text",
2538 /*expected_count*/ 0);
2539
2540 // Move the endpoint to the end of the document. Verify all text content.
2542 text_range_provider, TextPatternRangeEndpoint_End, textunit,
2543 /*count*/ 1,
2544 /*expected_text*/ L"more texteven more text",
2545 /*expected_count*/ 1);
2546
2547 // Verify no moves occur since the end is already at the end of the document
2549 text_range_provider, TextPatternRangeEndpoint_End, textunit,
2550 /*count*/ 5,
2551 /*expected_text*/ L"more texteven more text",
2552 /*expected_count*/ 0);
2553
2554 // Move the end before the start
2555 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(text_range_provider,
2556 TextPatternRangeEndpoint_End, textunit,
2557 /*count*/ -4,
2558 /*expected_text*/ L"",
2559 /*expected_count*/ -1);
2560
2561 // Move the end back to the end of the document. The text content
2562 // should now include the entire document since end was previously
2563 // moved before start.
2565 text_range_provider, TextPatternRangeEndpoint_End, textunit,
2566 /*count*/ 1,
2567 /*expected_text*/ L"some textmore texteven more text",
2568 /*expected_count*/ 1);
2569
2570 // Move the start point to the end
2571 EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT(text_range_provider,
2572 TextPatternRangeEndpoint_Start, textunit,
2573 /*count*/ 3,
2574 /*expected_text*/ L"",
2575 /*expected_count*/ 1);
2576
2577 // Move the start point back to the beginning
2579 text_range_provider, TextPatternRangeEndpoint_Start, textunit,
2580 /*count*/ -3,
2581 /*expected_text*/ L"some textmore texteven more text",
2582 /*expected_count*/ -1);
2583 }
2584}

◆ TEST_F() [74/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestITextRangeProviderMoveEndpointByRange   
)

Definition at line 3578 of file ax_platform_node_textrangeprovider_win_unittest.cc.

3579 {
3580 Init(BuildTextDocument({"some text", "more text"}));
3581
3582 AXNode* root_node = GetRootAsAXNode();
3583 AXNode* text_node = root_node->children()[0];
3584 AXNode* more_text_node = root_node->children()[1];
3585 AXPlatformNodeWin* owner =
3586 static_cast<AXPlatformNodeWin*>(AXPlatformNodeFromNode(root_node));
3587 ASSERT_NE(owner, nullptr);
3588
3589 // Text range for the document, which contains text "some textmore text".
3590 ComPtr<IRawElementProviderSimple> root_node_raw =
3591 QueryInterfaceFromNode<IRawElementProviderSimple>(root_node);
3592 ComPtr<ITextProvider> document_provider;
3593 EXPECT_HRESULT_SUCCEEDED(
3594 root_node_raw->GetPatternProvider(UIA_TextPatternId, &document_provider));
3595 ComPtr<ITextRangeProvider> document_text_range_provider;
3596 ComPtr<AXPlatformNodeTextRangeProviderWin> document_text_range;
3597
3598 // Text range related to "some text".
3599 ComPtr<IRawElementProviderSimple> text_node_raw =
3600 QueryInterfaceFromNode<IRawElementProviderSimple>(text_node);
3601 ComPtr<ITextProvider> text_provider;
3602 EXPECT_HRESULT_SUCCEEDED(
3603 text_node_raw->GetPatternProvider(UIA_TextPatternId, &text_provider));
3604 ComPtr<ITextRangeProvider> text_range_provider;
3605 ComPtr<AXPlatformNodeTextRangeProviderWin> text_range;
3606
3607 // Text range related to "more text".
3608 ComPtr<IRawElementProviderSimple> more_text_node_raw =
3609 QueryInterfaceFromNode<IRawElementProviderSimple>(more_text_node);
3610 ComPtr<ITextProvider> more_text_provider;
3611 EXPECT_HRESULT_SUCCEEDED(more_text_node_raw->GetPatternProvider(
3612 UIA_TextPatternId, &more_text_provider));
3613 ComPtr<ITextRangeProvider> more_text_range_provider;
3614 ComPtr<AXPlatformNodeTextRangeProviderWin> more_text_range;
3615
3616 // Move the start of document text range "some textmore text" to the end of
3617 // itself.
3618 // The start of document text range "some textmore text" is at the end of
3619 // itself.
3620 //
3621 // Before:
3622 // |s e|
3623 // "some textmore text"
3624 // After:
3625 // |s
3626 // e|
3627 // "some textmore text"
3628
3629 // Get the textRangeProvider for the document, which contains text
3630 // "some textmore text".
3631 EXPECT_HRESULT_SUCCEEDED(
3632 document_provider->get_DocumentRange(&document_text_range_provider));
3633 SetOwner(owner, document_text_range_provider.Get());
3634
3635 EXPECT_HRESULT_SUCCEEDED(document_text_range_provider->MoveEndpointByRange(
3636 TextPatternRangeEndpoint_Start, document_text_range_provider.Get(),
3637 TextPatternRangeEndpoint_End));
3638
3639 document_text_range_provider->QueryInterface(
3640 IID_PPV_ARGS(&document_text_range));
3641 EXPECT_EQ(*GetStart(document_text_range.Get()),
3642 *GetEnd(document_text_range.Get()));
3643
3644 // Move the end of document text range "some textmore text" to the start of
3645 // itself.
3646 // The end of document text range "some textmore text" is at the start of
3647 // itself.
3648 //
3649 // Before:
3650 // |s e|
3651 // "some textmore text"
3652 // After:
3653 // |s
3654 // e|
3655 // "some textmore text"
3656
3657 // Get the textRangeProvider for the document, which contains text
3658 // "some textmore text".
3659 EXPECT_HRESULT_SUCCEEDED(
3660 document_provider->get_DocumentRange(&document_text_range_provider));
3661 SetOwner(owner, document_text_range_provider.Get());
3662
3663 EXPECT_HRESULT_SUCCEEDED(document_text_range_provider->MoveEndpointByRange(
3664 TextPatternRangeEndpoint_Start, document_text_range_provider.Get(),
3665 TextPatternRangeEndpoint_End));
3666
3667 document_text_range_provider->QueryInterface(
3668 IID_PPV_ARGS(&document_text_range));
3669 EXPECT_EQ(*GetStart(document_text_range.Get()),
3670 *GetEnd(document_text_range.Get()));
3671
3672 // Move the start of document text range "some textmore text" to the start
3673 // of text range "more text". The start of document text range "some
3674 // textmore text" is at the start of text range "more text". The end of
3675 // document range does not change.
3676 //
3677 // Before:
3678 // |s e|
3679 // "some textmore text"
3680 // After:
3681 // |s e|
3682 // "some textmore text"
3683
3684 // Get the textRangeProvider for the document, which contains text
3685 // "some textmore text".
3686 EXPECT_HRESULT_SUCCEEDED(
3687 document_provider->get_DocumentRange(&document_text_range_provider));
3688 SetOwner(owner, document_text_range_provider.Get());
3689 // Get the textRangeProvider for more_text_node which contains "more text".
3690 EXPECT_HRESULT_SUCCEEDED(
3691 more_text_provider->get_DocumentRange(&more_text_range_provider));
3692 SetOwner(owner, more_text_range_provider.Get());
3693
3694 EXPECT_HRESULT_SUCCEEDED(document_text_range_provider->MoveEndpointByRange(
3695 TextPatternRangeEndpoint_Start, more_text_range_provider.Get(),
3696 TextPatternRangeEndpoint_Start));
3697
3698 document_text_range_provider->QueryInterface(
3699 IID_PPV_ARGS(&document_text_range));
3700 more_text_range_provider->QueryInterface(IID_PPV_ARGS(&more_text_range));
3701 EXPECT_EQ(*GetStart(document_text_range.Get()),
3702 *GetStart(more_text_range.Get()));
3703
3704 // Move the end of document text range "some textmore text" to the end of
3705 // text range "some text".
3706 // The end of document text range "some textmore text" is at the end of text
3707 // range "some text". The start of document range does not change.
3708 //
3709 // Before:
3710 // |s e|
3711 // "some textmore text"
3712 // After:
3713 // |s e|
3714 // "some textmore text"
3715
3716 // Get the textRangeProvider for the document, which contains text
3717 // "some textmore text".
3718 EXPECT_HRESULT_SUCCEEDED(
3719 document_provider->get_DocumentRange(&document_text_range_provider));
3720 SetOwner(owner, document_text_range_provider.Get());
3721 // Get the textRangeProvider for text_node which contains "some text".
3722 EXPECT_HRESULT_SUCCEEDED(
3723 text_provider->get_DocumentRange(&text_range_provider));
3724 SetOwner(owner, text_range_provider.Get());
3725
3726 EXPECT_HRESULT_SUCCEEDED(document_text_range_provider->MoveEndpointByRange(
3727 TextPatternRangeEndpoint_End, text_range_provider.Get(),
3728 TextPatternRangeEndpoint_End));
3729
3730 document_text_range_provider->QueryInterface(
3731 IID_PPV_ARGS(&document_text_range));
3732 text_range_provider->QueryInterface(IID_PPV_ARGS(&text_range));
3733 EXPECT_EQ(*GetEnd(document_text_range.Get()), *GetEnd(text_range.Get()));
3734
3735 // Move the end of text range "more text" to the start of
3736 // text range "some text". Since the order of the endpoints being moved
3737 // (those of "more text") have to be ensured, both endpoints of "more text"
3738 // is at the start of "some text".
3739 //
3740 // Before:
3741 // |s e|
3742 // "some textmore text"
3743 // After:
3744 // e|
3745 // |s
3746 // "some textmore text"
3747
3748 // Get the textRangeProvider for text_node which contains "some text".
3749 EXPECT_HRESULT_SUCCEEDED(
3750 text_provider->get_DocumentRange(&text_range_provider));
3751 SetOwner(owner, document_text_range_provider.Get());
3752 // Get the textRangeProvider for more_text_node which contains "more text".
3753 EXPECT_HRESULT_SUCCEEDED(
3754 more_text_provider->get_DocumentRange(&more_text_range_provider));
3755 SetOwner(owner, more_text_range_provider.Get());
3756
3757 EXPECT_HRESULT_SUCCEEDED(more_text_range_provider->MoveEndpointByRange(
3758 TextPatternRangeEndpoint_End, text_range_provider.Get(),
3759 TextPatternRangeEndpoint_Start));
3760
3761 text_range_provider->QueryInterface(IID_PPV_ARGS(&text_range));
3762 more_text_range_provider->QueryInterface(IID_PPV_ARGS(&more_text_range));
3763 EXPECT_EQ(*GetEnd(more_text_range.Get()), *GetStart(text_range.Get()));
3764 EXPECT_EQ(*GetStart(more_text_range.Get()), *GetStart(text_range.Get()));
3765
3766 // Move the start of text range "some text" to the end of text range
3767 // "more text". Since the order of the endpoints being moved (those
3768 // of "some text") have to be ensured, both endpoints of "some text" is at
3769 // the end of "more text".
3770 //
3771 // Before:
3772 // |s e|
3773 // "some textmore text"
3774 // After:
3775 // |s
3776 // e|
3777 // "some textmore text"
3778
3779 // Get the textRangeProvider for text_node which contains "some text".
3780 EXPECT_HRESULT_SUCCEEDED(
3781 text_provider->get_DocumentRange(&text_range_provider));
3782 SetOwner(owner, text_range_provider.Get());
3783 // Get the textRangeProvider for more_text_node which contains "more text".
3784 EXPECT_HRESULT_SUCCEEDED(
3785 more_text_provider->get_DocumentRange(&more_text_range_provider));
3786 SetOwner(owner, more_text_range_provider.Get());
3787
3788 EXPECT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByRange(
3789 TextPatternRangeEndpoint_Start, more_text_range_provider.Get(),
3790 TextPatternRangeEndpoint_End));
3791
3792 text_range_provider->QueryInterface(IID_PPV_ARGS(&text_range));
3793 more_text_range_provider->QueryInterface(IID_PPV_ARGS(&more_text_range));
3794 EXPECT_EQ(*GetStart(text_range.Get()), *GetEnd(more_text_range.Get()));
3795 EXPECT_EQ(*GetEnd(text_range.Get()), *GetEnd(more_text_range.Get()));
3796}

◆ TEST_F() [75/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestITextRangeProviderSelect   
)

Definition at line 4875 of file ax_platform_node_textrangeprovider_win_unittest.cc.

4875 {
4876 Init(BuildTextDocument({"some text", "more text2"}));
4877 AXNode* root_node = GetRootAsAXNode();
4878
4879 // Text range for the document, which contains text "some textmore text2".
4880 ComPtr<IRawElementProviderSimple> root_node_raw =
4881 QueryInterfaceFromNode<IRawElementProviderSimple>(root_node);
4882 ComPtr<ITextProvider> document_provider;
4883 ComPtr<ITextRangeProvider> document_text_range_provider;
4884 ComPtr<AXPlatformNodeTextRangeProviderWin> document_text_range;
4885 EXPECT_HRESULT_SUCCEEDED(
4886 root_node_raw->GetPatternProvider(UIA_TextPatternId, &document_provider));
4887 EXPECT_HRESULT_SUCCEEDED(
4888 document_provider->get_DocumentRange(&document_text_range_provider));
4889 document_text_range_provider->QueryInterface(
4890 IID_PPV_ARGS(&document_text_range));
4891 AXPlatformNodeWin* owner_platform =
4892 static_cast<AXPlatformNodeWin*>(AXPlatformNodeFromNode(root_node));
4893 ASSERT_NE(owner_platform, nullptr);
4894 SetOwner(owner_platform, document_text_range_provider.Get());
4895
4896 // Text range related to "some text".
4897 ComPtr<ITextRangeProvider> text_range_provider;
4898 GetTextRangeProviderFromTextNode(text_range_provider,
4899 root_node->children()[0]);
4900 ComPtr<AXPlatformNodeTextRangeProviderWin> text_range;
4901 EXPECT_HRESULT_SUCCEEDED(
4902 text_range_provider->QueryInterface(IID_PPV_ARGS(&text_range)));
4903
4904 // Text range related to "more text2".
4905 ComPtr<ITextRangeProvider> more_text_range_provider;
4906 GetTextRangeProviderFromTextNode(more_text_range_provider,
4907 root_node->children()[1]);
4908 SetOwner(owner_platform, more_text_range_provider.Get());
4909 ComPtr<AXPlatformNodeTextRangeProviderWin> more_text_range;
4910 more_text_range_provider->QueryInterface(IID_PPV_ARGS(&more_text_range));
4911
4912 AXPlatformNodeDelegate* delegate =
4913 GetOwner(document_text_range.Get())->GetDelegate();
4914
4915 ComPtr<ITextRangeProvider> selected_text_range_provider;
4917 LONG index = 0;
4918 LONG ubound;
4919 LONG lbound;
4920
4921 // Text range "some text" performs select.
4922 {
4923 text_range_provider->Select();
4924
4925 // Verify selection.
4926 AXTree::Selection unignored_selection = delegate->GetUnignoredSelection();
4927 EXPECT_EQ(3, unignored_selection.anchor_object_id);
4928 EXPECT_EQ(3, unignored_selection.focus_object_id);
4929 EXPECT_EQ(0, unignored_selection.anchor_offset);
4930 EXPECT_EQ(9, unignored_selection.focus_offset);
4931
4932 // Verify the content of the selection.
4933 document_provider->GetSelection(selection.Receive());
4934 ASSERT_NE(nullptr, selection.Get());
4935
4936 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetUBound(selection.Get(), 1, &ubound));
4937 EXPECT_EQ(0, ubound);
4938 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetLBound(selection.Get(), 1, &lbound));
4939 EXPECT_EQ(0, lbound);
4940 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetElement(
4941 selection.Get(), &index,
4942 static_cast<void**>(&selected_text_range_provider)));
4943 SetOwner(owner_platform, selected_text_range_provider.Get());
4944 EXPECT_UIA_TEXTRANGE_EQ(selected_text_range_provider, L"some text");
4945
4946 selected_text_range_provider.Reset();
4947 selection.Reset();
4948 }
4949
4950 // Text range "more text2" performs select.
4951 {
4952 more_text_range_provider->Select();
4953
4954 // Verify selection
4955 AXTree::Selection unignored_selection = delegate->GetUnignoredSelection();
4956 EXPECT_EQ(5, unignored_selection.anchor_object_id);
4957 EXPECT_EQ(5, unignored_selection.focus_object_id);
4958 EXPECT_EQ(0, unignored_selection.anchor_offset);
4959 EXPECT_EQ(10, unignored_selection.focus_offset);
4960
4961 // Verify the content of the selection.
4962 document_provider->GetSelection(selection.Receive());
4963 ASSERT_NE(nullptr, selection.Get());
4964
4965 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetUBound(selection.Get(), 1, &ubound));
4966 EXPECT_EQ(0, ubound);
4967 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetLBound(selection.Get(), 1, &lbound));
4968 EXPECT_EQ(0, lbound);
4969 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetElement(
4970 selection.Get(), &index,
4971 static_cast<void**>(&selected_text_range_provider)));
4972 SetOwner(owner_platform, selected_text_range_provider.Get());
4973 EXPECT_UIA_TEXTRANGE_EQ(selected_text_range_provider, L"more text2");
4974
4975 selected_text_range_provider.Reset();
4976 selection.Reset();
4977 }
4978
4979 // Document text range "some textmore text2" performs select.
4980 {
4981 document_text_range_provider->Select();
4982
4983 // Verify selection.
4984 AXTree::Selection unignored_selection = delegate->GetUnignoredSelection();
4985 EXPECT_EQ(3, unignored_selection.anchor_object_id);
4986 EXPECT_EQ(5, unignored_selection.focus_object_id);
4987 EXPECT_EQ(0, unignored_selection.anchor_offset);
4988 EXPECT_EQ(10, unignored_selection.focus_offset);
4989
4990 // Verify the content of the selection.
4991 document_provider->GetSelection(selection.Receive());
4992 ASSERT_NE(nullptr, selection.Get());
4993
4994 document_provider->GetSelection(selection.Receive());
4995 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetUBound(selection.Get(), 1, &ubound));
4996 EXPECT_EQ(0, ubound);
4997 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetLBound(selection.Get(), 1, &lbound));
4998 EXPECT_EQ(0, lbound);
4999 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetElement(
5000 selection.Get(), &index,
5001 static_cast<void**>(&selected_text_range_provider)));
5002 SetOwner(owner_platform, selected_text_range_provider.Get());
5003 EXPECT_UIA_TEXTRANGE_EQ(selected_text_range_provider,
5004 L"some textmore text2");
5005 }
5006
5007 // A degenerate text range performs select.
5008 {
5009 // Move the endpoint of text range so it becomes degenerate, then select.
5010 text_range_provider->MoveEndpointByRange(TextPatternRangeEndpoint_Start,
5011 text_range_provider.Get(),
5012 TextPatternRangeEndpoint_End);
5013 text_range_provider->Select();
5014
5015 // Verify selection.
5016 AXTree::Selection unignored_selection = delegate->GetUnignoredSelection();
5017 EXPECT_EQ(3, unignored_selection.anchor_object_id);
5018 EXPECT_EQ(3, unignored_selection.focus_object_id);
5019 EXPECT_EQ(9, unignored_selection.anchor_offset);
5020 EXPECT_EQ(9, unignored_selection.focus_offset);
5021
5022 // Verify selection on degenerate range.
5023 document_provider->GetSelection(selection.Receive());
5024 ASSERT_NE(nullptr, selection.Get());
5025
5026 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetUBound(selection.Get(), 1, &ubound));
5027 EXPECT_EQ(0, ubound);
5028 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetLBound(selection.Get(), 1, &lbound));
5029 EXPECT_EQ(0, lbound);
5030 EXPECT_HRESULT_SUCCEEDED(SafeArrayGetElement(
5031 selection.Get(), &index,
5032 static_cast<void**>(&selected_text_range_provider)));
5033 SetOwner(owner_platform, selected_text_range_provider.Get());
5034 EXPECT_UIA_TEXTRANGE_EQ(selected_text_range_provider, L"");
5035
5036 selected_text_range_provider.Reset();
5037 selection.Reset();
5038 }
5039}

◆ TEST_F() [76/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestITextRangeProviderSelection   
)

Definition at line 3141 of file ax_platform_node_textrangeprovider_win_unittest.cc.

3141 {
3142 Init(BuildTextDocument({"some text"}));
3143
3144 ComPtr<ITextRangeProvider> text_range_provider;
3145 GetTextRangeProviderFromTextNode(text_range_provider, GetRootAsAXNode());
3146
3147 ASSERT_UIA_INVALIDOPERATION(text_range_provider->AddToSelection());
3148 ASSERT_UIA_INVALIDOPERATION(text_range_provider->RemoveFromSelection());
3149}

◆ TEST_F() [77/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestITextRangeProviderSelectListMarker   
)

Definition at line 5042 of file ax_platform_node_textrangeprovider_win_unittest.cc.

5043 {
5044 ui::AXNodeData root_data;
5045 root_data.id = 1;
5047
5048 ui::AXNodeData list_data;
5049 list_data.id = 2;
5050 list_data.role = ax::mojom::Role::kList;
5051 root_data.child_ids.push_back(list_data.id);
5052
5053 ui::AXNodeData list_item_data;
5054 list_item_data.id = 3;
5055 list_item_data.role = ax::mojom::Role::kListItem;
5056 list_data.child_ids.push_back(list_item_data.id);
5057
5058 ui::AXNodeData list_marker;
5059 list_marker.id = 4;
5060 list_marker.role = ax::mojom::Role::kListMarker;
5061 list_item_data.child_ids.push_back(list_marker.id);
5062
5063 ui::AXNodeData static_text_data;
5064 static_text_data.id = 5;
5065 static_text_data.role = ax::mojom::Role::kStaticText;
5066 static_text_data.SetName("1. ");
5067 list_marker.child_ids.push_back(static_text_data.id);
5068
5069 ui::AXNodeData list_item_text_data;
5070 list_item_text_data.id = 6;
5071 list_item_text_data.role = ax::mojom::Role::kStaticText;
5072 list_item_text_data.SetName("First Item");
5073 list_item_data.child_ids.push_back(list_item_text_data.id);
5074
5076 ui::AXTreeData tree_data;
5078 update.tree_data = tree_data;
5079 update.has_tree_data = true;
5080 update.root_id = root_data.id;
5081 update.nodes = {root_data, list_data, list_item_data,
5082 list_marker, static_text_data, list_item_text_data};
5083 Init(update);
5084 AXNode* root_node = GetRootAsAXNode();
5085
5086 // Text range related to "1. ".
5087 AXNode* list_node = root_node->children()[0];
5088 AXNode* list_item_node = list_node->children()[0];
5089 AXNode* list_marker_node = list_item_node->children()[0];
5090 ComPtr<ITextRangeProvider> list_marker_text_range_provider;
5091 GetTextRangeProviderFromTextNode(list_marker_text_range_provider,
5092 list_marker_node->children()[0]);
5093
5094 // A list marker text range performs select.
5095 EXPECT_HRESULT_SUCCEEDED(list_marker_text_range_provider->Select());
5096
5097 // Verify selection was not performed on list marker range.
5099 ComPtr<IRawElementProviderSimple> root_node_raw =
5100 QueryInterfaceFromNode<IRawElementProviderSimple>(root_node);
5101 ComPtr<ITextProvider> document_provider;
5102 EXPECT_HRESULT_SUCCEEDED(
5103 root_node_raw->GetPatternProvider(UIA_TextPatternId, &document_provider));
5104 EXPECT_HRESULT_SUCCEEDED(
5105 document_provider->GetSelection(selection.Receive()));
5106 ASSERT_EQ(nullptr, selection.Get());
5107 selection.Reset();
5108}

◆ TEST_F() [78/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestNormalizeTextRangeInsideIgnoredNodes   
)

Definition at line 6110 of file ax_platform_node_textrangeprovider_win_unittest.cc.

6111 {
6112 ui::AXTreeUpdate initial_state;
6114 initial_state.tree_data.tree_id = tree_id;
6115 initial_state.has_tree_data = true;
6116 initial_state.root_id = 1;
6117 initial_state.nodes.resize(4);
6118 initial_state.nodes[0].id = 1;
6119 initial_state.nodes[0].child_ids = {2, 3, 4};
6120 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
6121 initial_state.nodes[1].id = 2;
6122 initial_state.nodes[1].role = ax::mojom::Role::kStaticText;
6123 initial_state.nodes[1].SetName("before");
6124 initial_state.nodes[2].id = 3;
6125 initial_state.nodes[2].role = ax::mojom::Role::kStaticText;
6126 initial_state.nodes[2].AddState(ax::mojom::State::kIgnored);
6127 initial_state.nodes[2].SetName("ignored");
6128 initial_state.nodes[3].id = 4;
6129 initial_state.nodes[3].role = ax::mojom::Role::kStaticText;
6130 initial_state.nodes[3].SetName("after");
6131
6132 Init(initial_state);
6133 const AXTree* tree = GetTree();
6134 const AXNode* ignored_node = tree->GetFromId(3);
6135
6136 // Making |owner| AXID:1 so that |TestAXNodeWrapper::BuildAllWrappers|
6137 // will build the entire tree.
6138 AXPlatformNodeWin* owner = static_cast<AXPlatformNodeWin*>(
6139 AXPlatformNodeFromNode(GetNodeFromTree(tree_id, 1)));
6140
6141 // start: TextPosition, anchor_id=3, text_offset=1, annotated_text=i<g>nored
6142 // end : TextPosition, anchor_id=3, text_offset=6, annotated_text=ignore<d>
6143 ComPtr<AXPlatformNodeTextRangeProviderWin> ignored_range_win;
6144 CreateTextRangeProviderWin(
6145 ignored_range_win, owner,
6146 /*start_anchor=*/ignored_node, /*start_offset=*/0,
6147 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
6148 /*end_anchor=*/ignored_node, /*end_offset=*/0,
6149 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
6150
6151 EXPECT_TRUE(GetStart(ignored_range_win.Get())->IsIgnored());
6152 EXPECT_TRUE(GetEnd(ignored_range_win.Get())->IsIgnored());
6153
6154 auto original_start = GetStart(ignored_range_win.Get())->Clone();
6155 auto original_end = GetEnd(ignored_range_win.Get())->Clone();
6156
6157 auto normalized_start = GetStart(ignored_range_win.Get())->Clone();
6158 auto normalized_end = GetEnd(ignored_range_win.Get())->Clone();
6159 NormalizeTextRange(ignored_range_win.Get(), normalized_start, normalized_end);
6160 // Verify that the original range was not changed by normalization.
6161 ExpectPositionsEqual(original_start, GetStart(ignored_range_win.Get()));
6162 ExpectPositionsEqual(original_end, GetEnd(ignored_range_win.Get()));
6163
6164 EXPECT_FALSE(normalized_start->IsIgnored());
6165 EXPECT_FALSE(normalized_end->IsIgnored());
6166 EXPECT_LE(*GetStart(ignored_range_win.Get()), *normalized_start);
6167 EXPECT_LE(*GetEnd(ignored_range_win.Get()), *normalized_end);
6168 EXPECT_LE(*normalized_start, *normalized_end);
6169
6170 // Remove the last node, forcing |NormalizeTextRange| to normalize
6171 // using the opposite AdjustmentBehavior.
6173 update.nodes.resize(1);
6174 update.nodes[0] = initial_state.nodes[0];
6175 update.nodes[0].child_ids = {2, 3};
6176 ASSERT_TRUE(GetTree()->Unserialize(update));
6177
6178 original_start = GetStart(ignored_range_win.Get())->Clone();
6179 original_end = GetEnd(ignored_range_win.Get())->Clone();
6180
6181 normalized_start = GetStart(ignored_range_win.Get())->Clone();
6182 normalized_end = GetEnd(ignored_range_win.Get())->Clone();
6183 NormalizeTextRange(ignored_range_win.Get(), normalized_start, normalized_end);
6184 // Verify that the original range was not changed by normalization.
6185 ExpectPositionsEqual(original_start, GetStart(ignored_range_win.Get()));
6186 ExpectPositionsEqual(original_end, GetEnd(ignored_range_win.Get()));
6187
6188 EXPECT_FALSE(normalized_start->IsIgnored());
6189 EXPECT_FALSE(normalized_end->IsIgnored());
6190 EXPECT_GE(*GetStart(ignored_range_win.Get()), *normalized_start);
6191 EXPECT_GE(*GetEnd(ignored_range_win.Get()), *normalized_end);
6192 EXPECT_LE(*normalized_start, *normalized_end);
6193}

◆ TEST_F() [79/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestNormalizeTextRangePastEndOfDocument   
)

Definition at line 5976 of file ax_platform_node_textrangeprovider_win_unittest.cc.

5977 {
5978 ui::AXTreeUpdate initial_state;
5980 initial_state.tree_data.tree_id = tree_id;
5981 initial_state.has_tree_data = true;
5982 initial_state.root_id = 1;
5983 initial_state.nodes.resize(3);
5984 initial_state.nodes[0].id = 1;
5985 initial_state.nodes[0].child_ids = {2};
5986 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
5987 initial_state.nodes[1].id = 2;
5988 initial_state.nodes[1].child_ids = {3};
5989 initial_state.nodes[1].role = ax::mojom::Role::kStaticText;
5990 initial_state.nodes[1].SetName("aaa");
5991 initial_state.nodes[2].id = 3;
5992 initial_state.nodes[2].role = ax::mojom::Role::kInlineTextBox;
5993 initial_state.nodes[2].SetName("aaa");
5994
5995 Init(initial_state);
5996
5997 ComPtr<ITextRangeProvider> text_range_provider;
5998 GetTextRangeProviderFromTextNode(text_range_provider,
5999 GetNodeFromTree(tree_id, 3));
6000
6001 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"aaa");
6003 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Character,
6004 /*count*/ 2,
6005 /*expected_text*/ L"a",
6006 /*expected_count*/ 2);
6007
6008 ComPtr<AXPlatformNodeTextRangeProviderWin> text_range_provider_win;
6009 text_range_provider->QueryInterface(IID_PPV_ARGS(&text_range_provider_win));
6010
6011 const AXNodePosition::AXPositionInstance start_after_move =
6012 GetStart(text_range_provider_win.Get())->Clone();
6013 const AXNodePosition::AXPositionInstance end_after_move =
6014 GetEnd(text_range_provider_win.Get())->Clone();
6015 EXPECT_LT(*start_after_move, *end_after_move);
6016
6018 update.nodes.resize(2);
6019 update.nodes[0] = initial_state.nodes[1];
6020 update.nodes[0].SetName("aa");
6021 update.nodes[1] = initial_state.nodes[2];
6022 update.nodes[1].SetName("aa");
6023 ASSERT_TRUE(GetTree()->Unserialize(update));
6024
6025 auto* text_range = text_range_provider_win.Get();
6026
6027 auto original_start = GetStart(text_range)->Clone();
6028 auto original_end = GetEnd(text_range)->Clone();
6029
6030 auto normalized_start = GetStart(text_range)->Clone();
6031 auto normalized_end = GetEnd(text_range)->Clone();
6032 NormalizeTextRange(text_range, normalized_start, normalized_end);
6033 // Verify that the original range was not changed by normalization.
6034 ExpectPositionsEqual(original_start, GetStart(text_range));
6035 ExpectPositionsEqual(original_end, GetEnd(text_range));
6036
6037 EXPECT_EQ(*start_after_move, *normalized_start);
6038 EXPECT_EQ(*end_after_move, *normalized_end);
6039}

◆ TEST_F() [80/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestNormalizeTextRangePastEndOfDocumentWithIgnoredNodes   
)

Definition at line 6041 of file ax_platform_node_textrangeprovider_win_unittest.cc.

6042 {
6043 ui::AXTreeUpdate initial_state;
6045 initial_state.tree_data.tree_id = tree_id;
6046 initial_state.has_tree_data = true;
6047 initial_state.root_id = 1;
6048 initial_state.nodes.resize(4);
6049 initial_state.nodes[0].id = 1;
6050 initial_state.nodes[0].child_ids = {2};
6051 initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea;
6052 initial_state.nodes[1].id = 2;
6053 initial_state.nodes[1].child_ids = {3, 4};
6054 initial_state.nodes[1].role = ax::mojom::Role::kStaticText;
6055 initial_state.nodes[1].SetName("aaa");
6056 initial_state.nodes[2].id = 3;
6057 initial_state.nodes[2].role = ax::mojom::Role::kInlineTextBox;
6058 initial_state.nodes[2].SetName("aaa");
6059 initial_state.nodes[3].id = 4;
6060 initial_state.nodes[3].role = ax::mojom::Role::kInlineTextBox;
6061 initial_state.nodes[3].AddState(ax::mojom::State::kIgnored);
6062 initial_state.nodes[3].SetName("ignored");
6063
6064 Init(initial_state);
6065
6066 ComPtr<ITextRangeProvider> text_range_provider;
6067 GetTextRangeProviderFromTextNode(text_range_provider,
6068 GetNodeFromTree(tree_id, 3));
6069
6070 EXPECT_UIA_TEXTRANGE_EQ(text_range_provider, L"aaa");
6072 text_range_provider, TextPatternRangeEndpoint_Start, TextUnit_Character,
6073 /*count*/ 2,
6074 /*expected_text*/ L"a",
6075 /*expected_count*/ 2);
6076
6077 ComPtr<AXPlatformNodeTextRangeProviderWin> text_range_provider_win;
6078 text_range_provider->QueryInterface(IID_PPV_ARGS(&text_range_provider_win));
6079
6080 const AXNodePosition::AXPositionInstance start_after_move =
6081 GetStart(text_range_provider_win.Get())->Clone();
6082 const AXNodePosition::AXPositionInstance end_after_move =
6083 GetEnd(text_range_provider_win.Get())->Clone();
6084 EXPECT_LT(*start_after_move, *end_after_move);
6085
6087 update.nodes.resize(2);
6088 update.nodes[0] = initial_state.nodes[1];
6089 update.nodes[0].SetName("aa");
6090 update.nodes[1] = initial_state.nodes[2];
6091 update.nodes[1].SetName("aa");
6092 ASSERT_TRUE(GetTree()->Unserialize(update));
6093
6094 auto* text_range = text_range_provider_win.Get();
6095
6096 auto original_start = GetStart(text_range)->Clone();
6097 auto original_end = GetEnd(text_range)->Clone();
6098
6099 auto normalized_start = GetStart(text_range)->Clone();
6100 auto normalized_end = GetEnd(text_range)->Clone();
6101 NormalizeTextRange(text_range, normalized_start, normalized_end);
6102 // Verify that the original range was not changed by normalization.
6103 ExpectPositionsEqual(original_start, GetStart(text_range));
6104 ExpectPositionsEqual(original_end, GetEnd(text_range));
6105
6106 EXPECT_EQ(*start_after_move, *normalized_start);
6107 EXPECT_EQ(*end_after_move, *normalized_end);
6108}

◆ TEST_F() [81/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestNormalizeTextRangeSpanIgnoredNodes   
)

Definition at line 6195 of file ax_platform_node_textrangeprovider_win_unittest.cc.

6196 {
6197 ui::AXNodeData root_data;
6198 root_data.id = 1;
6200
6201 ui::AXNodeData before_text;
6202 before_text.id = 2;
6203 before_text.role = ax::mojom::Role::kStaticText;
6204 before_text.SetName("before");
6205 root_data.child_ids.push_back(before_text.id);
6206
6207 ui::AXNodeData ignored_text1;
6208 ignored_text1.id = 3;
6209 ignored_text1.role = ax::mojom::Role::kStaticText;
6210 ignored_text1.AddState(ax::mojom::State::kIgnored);
6211 ignored_text1.SetName("ignored1");
6212 root_data.child_ids.push_back(ignored_text1.id);
6213
6214 ui::AXNodeData ignored_text2;
6215 ignored_text2.id = 4;
6216 ignored_text2.role = ax::mojom::Role::kStaticText;
6217 ignored_text2.AddState(ax::mojom::State::kIgnored);
6218 ignored_text2.SetName("ignored2");
6219 root_data.child_ids.push_back(ignored_text2.id);
6220
6221 ui::AXNodeData after_text;
6222 after_text.id = 5;
6224 after_text.SetName("after");
6225 root_data.child_ids.push_back(after_text.id);
6226
6229 update.root_id = root_data.id;
6230 update.tree_data.tree_id = tree_id;
6231 update.has_tree_data = true;
6232 update.nodes = {root_data, before_text, ignored_text1, ignored_text2,
6233 after_text};
6234
6235 Init(update);
6236 const AXTree* tree = GetTree();
6237
6238 const AXNode* before_text_node = tree->GetFromId(before_text.id);
6239 const AXNode* after_text_node = tree->GetFromId(after_text.id);
6240
6241 // Making |owner| AXID:1 so that |TestAXNodeWrapper::BuildAllWrappers|
6242 // will build the entire tree.
6243 AXPlatformNodeWin* owner = static_cast<AXPlatformNodeWin*>(
6244 AXPlatformNodeFromNode(GetNodeFromTree(tree_id, 1)));
6245
6246 // Original range before NormalizeTextRange()
6247 // |before<>||ignored1||ignored2||<a>fter|
6248 // |-----------------------|
6249 // start: TextPosition, anchor_id=2, text_offset=6, annotated_text=before<>
6250 // end : TextPosition, anchor_id=5, text_offset=0, annotated_text=<a>fter
6251 ComPtr<AXPlatformNodeTextRangeProviderWin> range_span_ignored_nodes;
6252 CreateTextRangeProviderWin(
6253 range_span_ignored_nodes, owner,
6254 /*start_anchor=*/before_text_node, /*start_offset=*/6,
6255 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
6256 /*end_anchor=*/after_text_node, /*end_offset=*/0,
6257 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
6258
6259 auto original_start = GetStart(range_span_ignored_nodes.Get())->Clone();
6260 auto original_end = GetEnd(range_span_ignored_nodes.Get())->Clone();
6261
6262 // Normalized range after NormalizeTextRange()
6263 // |before||ignored1||ignored2||<a>fter|
6264 // |-|
6265 AXNodePosition::AXPositionInstance normalized_start =
6266 GetStart(range_span_ignored_nodes.Get())->Clone();
6267 AXNodePosition::AXPositionInstance normalized_end =
6268 GetEnd(range_span_ignored_nodes.Get())->Clone();
6269 NormalizeTextRange(range_span_ignored_nodes.Get(), normalized_start,
6270 normalized_end);
6271 // Verify that the original range was not changed by normalization.
6272 ExpectPositionsEqual(original_start,
6273 GetStart(range_span_ignored_nodes.Get()));
6274 ExpectPositionsEqual(original_end, GetEnd(range_span_ignored_nodes.Get()));
6275
6276 EXPECT_EQ(*normalized_start, *normalized_end);
6277
6278 EXPECT_TRUE(normalized_start->IsTextPosition());
6279 EXPECT_TRUE(normalized_start->AtStartOfAnchor());
6280 EXPECT_EQ(5, normalized_start->anchor_id());
6281 EXPECT_EQ(0, normalized_start->text_offset());
6282
6283 EXPECT_TRUE(normalized_end->IsTextPosition());
6284 EXPECT_TRUE(normalized_end->AtStartOfAnchor());
6285 EXPECT_EQ(5, normalized_end->anchor_id());
6286 EXPECT_EQ(0, normalized_end->text_offset());
6287}

◆ TEST_F() [82/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestReplaceStartAndEndEndpointNode   
)

Definition at line 6524 of file ax_platform_node_textrangeprovider_win_unittest.cc.

6525 {
6526 // This test updates the tree structure to ensure that the text range is still
6527 // valid after a text node gets replaced by another one. This case occurs
6528 // every time an AT's focus moves to a node whose style is affected by focus,
6529 // thus generating a tree update.
6530 //
6531 // ++1 kRootWebArea
6532 // ++++2 kGroup (ignored)
6533 // ++++++3 kStaticText/++++4 kStaticText (replacement node)
6534 // ++++5 kStaticText/++++6 kStaticText (replacement node)
6535 AXNodeData root_1;
6536 AXNodeData group_2;
6537 AXNodeData text_3;
6538 AXNodeData text_4;
6539 AXNodeData text_5;
6540 AXNodeData text_6;
6541
6542 root_1.id = 1;
6543 group_2.id = 2;
6544 text_3.id = 3;
6545 text_4.id = 4;
6546 text_5.id = 5;
6547 text_6.id = 6;
6548
6550 root_1.child_ids = {text_3.id, text_5.id};
6551
6552 group_2.role = ax::mojom::Role::kGroup;
6554 group_2.child_ids = {text_3.id};
6555
6557 text_3.SetName("some text");
6558
6559 // Replacement node of |text_3|.
6561 text_4.SetName("some text");
6562
6564 text_5.SetName("more text");
6565
6566 // Replacement node of |text_5|.
6568 text_6.SetName("more text");
6569
6572 update.root_id = root_1.id;
6573 update.tree_data.tree_id = tree_id;
6574 update.has_tree_data = true;
6575 update.nodes = {root_1, text_3, text_5};
6576
6577 Init(update);
6578 const AXTree* tree = GetTree();
6579
6580 const AXNode* text_3_node = tree->GetFromId(text_3.id);
6581 const AXNode* text_5_node = tree->GetFromId(text_5.id);
6582
6583 // Create a position at MaxTextOffset.
6584 // Making |owner| AXID:1 so that |TestAXNodeWrapper::BuildAllWrappers|
6585 // will build the entire tree.
6586 AXPlatformNodeWin* owner = static_cast<AXPlatformNodeWin*>(
6587 AXPlatformNodeFromNode(GetNodeFromTree(tree_id, 1)));
6588
6589 // start: TextPosition, anchor_id=3, text_offset=0, annotated_text=<s>ome text
6590 // end : TextPosition, anchor_id=5, text_offset=9, annotated_text=more text<>
6591 ComPtr<AXPlatformNodeTextRangeProviderWin> range;
6592 CreateTextRangeProviderWin(
6593 range, owner,
6594 /*start_anchor*/ text_3_node, /*start_offset*/ 0,
6595 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
6596 /*end_anchor*/ text_5_node, /*end_offset*/ 9,
6597 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
6598
6599 EXPECT_UIA_TEXTRANGE_EQ(range, /*expected_text*/ L"some textmore text");
6600
6601 // 1. Replace the node on which |start_| is.
6602 {
6603 // Replace node |text_3| with |text_4|.
6604 root_1.child_ids = {text_4.id, text_5.id};
6605 AXTreeUpdate test_update;
6606 test_update.nodes = {root_1, text_4};
6607 ASSERT_TRUE(GetTree()->Unserialize(test_update));
6608
6609 // Replacing that node shouldn't impact the range.
6611 range->GetChildren(children.Receive());
6612 EXPECT_UIA_TEXTRANGE_EQ(range, /*expected_text*/ L"some textmore text");
6613
6614 // The |start_| endpoint should have moved to the root, skipping its ignored
6615 // parent.
6616 EXPECT_EQ(root_1.id, GetStart(range.Get())->anchor_id());
6617 EXPECT_EQ(0, GetStart(range.Get())->text_offset());
6618
6619 // The |end_| endpoint should not have moved.
6620 EXPECT_EQ(text_5.id, GetEnd(range.Get())->anchor_id());
6621 EXPECT_EQ(9, GetEnd(range.Get())->text_offset());
6622 }
6623
6624 // 2. Replace the node on which |end_| is.
6625 {
6626 // Replace node |text_4| with |text_5|.
6627 root_1.child_ids = {text_4.id, text_6.id};
6628 AXTreeUpdate test_update;
6629 test_update.nodes = {root_1, text_6};
6630 ASSERT_TRUE(GetTree()->Unserialize(test_update));
6631
6632 // Replacing that node shouldn't impact the range.
6634 range->GetChildren(children.Receive());
6635 EXPECT_UIA_TEXTRANGE_EQ(range, /*expected_text*/ L"some textmore text");
6636
6637 // The |start_| endpoint should still be on its parent.
6638 EXPECT_EQ(root_1.id, GetStart(range.Get())->anchor_id());
6639 EXPECT_EQ(0, GetStart(range.Get())->text_offset());
6640
6641 // The |end_| endpoint should have moved to its parent.
6642 EXPECT_EQ(root_1.id, GetEnd(range.Get())->anchor_id());
6643 EXPECT_EQ(18, GetEnd(range.Get())->text_offset());
6644 }
6645
6646 // 3. Replace the node on which |start_| and |end_| is.
6647 {
6648 // start: TextPosition, anchor_id=4, text_offset=0, annotated_text=<s>ome
6649 // end : TextPosition, anchor_id=4, text_offset=4, annotated_text=some<>
6650 const AXNode* text_4_node = tree->GetFromId(text_4.id);
6651 ComPtr<AXPlatformNodeTextRangeProviderWin> range_2;
6652 CreateTextRangeProviderWin(
6653 range_2, owner,
6654 /*start_anchor*/ text_4_node, /*start_offset*/ 0,
6655 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
6656 /*end_anchor*/ text_4_node, /*end_offset*/ 4,
6657 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
6658
6659 EXPECT_UIA_TEXTRANGE_EQ(range_2, /*expected_text*/ L"some");
6660
6661 // Replace node |text_4| with |text_3|.
6662 root_1.child_ids = {text_3.id, text_6.id};
6663 AXTreeUpdate test_update;
6664 test_update.nodes = {root_1, text_3};
6665 ASSERT_TRUE(GetTree()->Unserialize(test_update));
6666
6667 // Replacing that node shouldn't impact the range.
6669 range_2->GetChildren(children.Receive());
6670 EXPECT_UIA_TEXTRANGE_EQ(range_2, /*expected_text*/ L"some");
6671
6672 // The |start_| endpoint should have moved to its parent.
6673 EXPECT_EQ(root_1.id, GetStart(range_2.Get())->anchor_id());
6674 EXPECT_EQ(0, GetStart(range_2.Get())->text_offset());
6675
6676 // The |end_| endpoint should have moved to its parent.
6677 EXPECT_EQ(root_1.id, GetEnd(range_2.Get())->anchor_id());
6678 EXPECT_EQ(4, GetEnd(range_2.Get())->text_offset());
6679 }
6680}

◆ TEST_F() [83/325]

ui::TEST_F ( AXPlatformNodeTextRangeProviderTest  ,
TestReplaceStartAndEndEndpointRepeatRemoval   
)

Definition at line 7133 of file ax_platform_node_textrangeprovider_win_unittest.cc.

7134 {
7135 // This test updates the tree structure to ensure that the text range is still
7136 // valid after text nodes get removed repeatedly.
7137 //
7138 // ++1 kRootWebArea
7139 // ++++2 kStaticText
7140 // ++++3 kGroup (ignored)
7141 // ++++++4 kStaticText
7142 // ++++5 kStaticText
7143 AXNodeData root_1;
7144 AXNodeData text_2;
7145 AXNodeData group_3;
7146 AXNodeData text_4;
7147 AXNodeData text_5;
7148
7149 root_1.id = 1;
7150 text_2.id = 2;
7151 group_3.id = 3;
7152 text_4.id = 4;
7153 text_5.id = 5;
7154
7156 root_1.child_ids = {text_2.id, group_3.id, text_5.id};
7157
7159 text_2.SetName("text 2");
7160
7161 group_3.role = ax::mojom::Role::kGroup;
7163 group_3.child_ids = {text_4.id};
7164
7166 text_4.SetName("text 4");
7167
7169 text_5.SetName("text 5");
7170
7173 update.root_id = root_1.id;
7174 update.tree_data.tree_id = tree_id;
7175 update.has_tree_data = true;
7176 update.nodes = {root_1, text_2, group_3, text_4, text_5};
7177
7178 Init(update);
7179 const AXTree* tree = GetTree();
7180
7181 const AXNode* text_2_node = tree->GetFromId(text_2.id);
7182 const AXNode* text_4_node = tree->GetFromId(text_4.id);
7183
7184 // Making |owner| AXID:1 so that |TestAXNodeWrapper::BuildAllWrappers|
7185 // will build the entire tree.
7186 AXPlatformNodeWin* owner = static_cast<AXPlatformNodeWin*>(
7187 AXPlatformNodeFromNode(GetNodeFromTree(tree_id, 1)));
7188
7189 ComPtr<AXPlatformNodeTextRangeProviderWin> range;
7190 CreateTextRangeProviderWin(
7191 range, owner,
7192 /*start_anchor*/ text_2_node, /*start_offset*/ 0,
7193 /*start_affinity*/ ax::mojom::TextAffinity::kDownstream,
7194 /*end_anchor*/ text_4_node, /*end_offset*/ 0,
7195 /*end_affinity*/ ax::mojom::TextAffinity::kDownstream);
7196
7197 EXPECT_UIA_TEXTRANGE_EQ(range, /*expected_text*/ L"text 2");
7198
7199 // start: TextPosition, anchor_id=2, text_offset=0, annotated_text=<t>ext2
7200 // end : TextPosition, anchor_id=4, text_offset=0, annotated_text=<>text4
7201 // 1. Remove |text_4| which |end_| is anchored on.
7202 {
7203 // Remove node |text_4|.
7204 group_3.child_ids = {};
7205 AXTreeUpdate test_update;
7206 test_update.nodes = {root_1, group_3};
7207 ASSERT_TRUE(GetTree()->Unserialize(test_update));
7208
7209 // Replacing that node should not impact the range.
7210 EXPECT_UIA_TEXTRANGE_EQ(range, /*expected_text*/ L"text 2");
7211 }
7212
7213 // start: TextPosition, anchor_id=2, text_offset=0, annotated_text=<>text2
7214 // end : TextPosition, anchor_id=2, text_offset=5, annotated_text=text2<>
7215 // 2. Remove |text_2|, which both |start_| and |end_| are anchored to and
7216 // replace with |text_5|.
7217 {
7218 root_1.child_ids = {group_3.id, text_5.id};
7219 AXTreeUpdate test_update;
7220 test_update.nodes = {root_1, group_3};
7221 ASSERT_TRUE(GetTree()->Unserialize(test_update));
7222
7223 // Removing that node should adjust the range to the |text_5|, as it took
7224 // |text_2|'s position.
7225 EXPECT_UIA_TEXTRANGE_EQ(range, /*expected_text*/ L"text 5");
7226 }
7227
7228 // start: TextPosition, anchor_id=5, text_offset=0, annotated_text=<>text5
7229 // end : TextPosition, anchor_id=5, text_offset=5, annotated_text=text5<>
7230 // 3. Remove |text_5|, which both |start_| and |end_| are pointing to.
7231 {
7232 root_1.child_ids = {group_3.id};
7233 AXTreeUpdate test_update;
7234 test_update.nodes = {root_1, group_3};
7235 ASSERT_TRUE(GetTree()->Unserialize(test_update));
7236
7237 // Removing the last text node should leave a degenerate range.
7238 EXPECT_UIA_TEXTRANGE_EQ(range, /*expected_text*/ L"");
7239 }
7240}

◆ TEST_F() [84/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
AccNavigate   
)

Definition at line 1069 of file ax_platform_node_win_unittest.cc.

1069 {
1071 root.id = 1;
1073
1074 AXNodeData child1;
1075 child1.id = 2;
1077 root.child_ids.push_back(2);
1078
1079 AXNodeData child2;
1080 child2.id = 3;
1082 root.child_ids.push_back(3);
1083
1084 Init(root, child1, child2);
1085 ComPtr<IAccessible> ia_root(GetRootIAccessible());
1086 ComPtr<IDispatch> disp_root;
1087 ASSERT_HRESULT_SUCCEEDED(ia_root.As(&disp_root));
1088 ScopedVariant var_root(disp_root.Get());
1089 ComPtr<IAccessible> ia_child1(
1090 IAccessibleFromNode(GetRootAsAXNode()->children()[0]));
1091 ComPtr<IDispatch> disp_child1;
1092 ASSERT_HRESULT_SUCCEEDED(ia_child1.As(&disp_child1));
1093 ScopedVariant var_child1(disp_child1.Get());
1094 ComPtr<IAccessible> ia_child2(
1095 IAccessibleFromNode(GetRootAsAXNode()->children()[1]));
1096 ComPtr<IDispatch> disp_child2;
1097 ASSERT_HRESULT_SUCCEEDED(ia_child2.As(&disp_child2));
1098 ScopedVariant var_child2(disp_child2.Get());
1100
1101 // Invalid arguments.
1102 EXPECT_EQ(
1103 E_INVALIDARG,
1104 ia_root->accNavigate(NAVDIR_NEXT, ScopedVariant::kEmptyVariant, nullptr));
1105 EXPECT_EQ(E_INVALIDARG,
1106 ia_child1->accNavigate(NAVDIR_NEXT, ScopedVariant::kEmptyVariant,
1107 end.AsInput()));
1108 EXPECT_EQ(VT_EMPTY, end.type());
1109
1110 // Navigating to first/last child should only be from self.
1111 EXPECT_EQ(E_INVALIDARG,
1112 ia_root->accNavigate(NAVDIR_FIRSTCHILD, var_root, end.AsInput()));
1113 EXPECT_EQ(VT_EMPTY, end.type());
1114 EXPECT_EQ(E_INVALIDARG,
1115 ia_root->accNavigate(NAVDIR_LASTCHILD, var_root, end.AsInput()));
1116 EXPECT_EQ(VT_EMPTY, end.type());
1117
1118 // Spatial directions are not supported.
1119 EXPECT_EQ(E_NOTIMPL, ia_child1->accNavigate(NAVDIR_UP, SELF, end.AsInput()));
1120 EXPECT_EQ(E_NOTIMPL, ia_root->accNavigate(NAVDIR_DOWN, SELF, end.AsInput()));
1121 EXPECT_EQ(E_NOTIMPL,
1122 ia_child1->accNavigate(NAVDIR_RIGHT, SELF, end.AsInput()));
1123 EXPECT_EQ(E_NOTIMPL,
1124 ia_child2->accNavigate(NAVDIR_LEFT, SELF, end.AsInput()));
1125 EXPECT_EQ(VT_EMPTY, end.type());
1126
1127 // Logical directions should be supported.
1128 EXPECT_EQ(S_OK, ia_root->accNavigate(NAVDIR_FIRSTCHILD, SELF, end.AsInput()));
1129 EXPECT_EQ(VT_DISPATCH, end.type());
1130 EXPECT_EQ(V_DISPATCH(var_child1.ptr()), V_DISPATCH(end.ptr()));
1131
1132 EXPECT_EQ(S_OK, ia_root->accNavigate(NAVDIR_LASTCHILD, SELF, end.AsInput()));
1133 EXPECT_EQ(VT_DISPATCH, end.type());
1134 EXPECT_EQ(V_DISPATCH(var_child2.ptr()), V_DISPATCH(end.ptr()));
1135
1136 EXPECT_EQ(S_OK, ia_child1->accNavigate(NAVDIR_NEXT, SELF, end.AsInput()));
1137 EXPECT_EQ(VT_DISPATCH, end.type());
1138 EXPECT_EQ(V_DISPATCH(var_child2.ptr()), V_DISPATCH(end.ptr()));
1139
1140 EXPECT_EQ(S_OK, ia_child2->accNavigate(NAVDIR_PREVIOUS, SELF, end.AsInput()));
1141 EXPECT_EQ(VT_DISPATCH, end.type());
1142 EXPECT_EQ(V_DISPATCH(var_child1.ptr()), V_DISPATCH(end.ptr()));
1143
1144 // Child indices can also be passed by variant.
1145 // Indices are one-based.
1146 EXPECT_EQ(S_OK,
1147 ia_root->accNavigate(NAVDIR_NEXT, ScopedVariant(1), end.AsInput()));
1148 EXPECT_EQ(VT_DISPATCH, end.type());
1149 EXPECT_EQ(V_DISPATCH(var_child2.ptr()), V_DISPATCH(end.ptr()));
1150
1151 EXPECT_EQ(S_OK, ia_root->accNavigate(NAVDIR_PREVIOUS, ScopedVariant(2),
1152 end.AsInput()));
1153 EXPECT_EQ(VT_DISPATCH, end.type());
1154 EXPECT_EQ(V_DISPATCH(var_child1.ptr()), V_DISPATCH(end.ptr()));
1155
1156 // Test out-of-bounds.
1157 EXPECT_EQ(S_FALSE,
1158 ia_child1->accNavigate(NAVDIR_PREVIOUS, SELF, end.AsInput()));
1159 EXPECT_EQ(VT_EMPTY, end.type());
1160 EXPECT_EQ(S_FALSE, ia_child2->accNavigate(NAVDIR_NEXT, SELF, end.AsInput()));
1161 EXPECT_EQ(VT_EMPTY, end.type());
1162
1163 EXPECT_EQ(S_FALSE, ia_root->accNavigate(NAVDIR_PREVIOUS, ScopedVariant(1),
1164 end.AsInput()));
1165 EXPECT_EQ(VT_EMPTY, end.type());
1166 EXPECT_EQ(S_FALSE,
1167 ia_root->accNavigate(NAVDIR_NEXT, ScopedVariant(2), end.AsInput()));
1168 EXPECT_EQ(VT_EMPTY, end.type());
1169}

◆ TEST_F() [85/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
AnnotatedImageName   
)

Definition at line 1171 of file ax_platform_node_win_unittest.cc.

1171 {
1172 std::vector<const wchar_t*> expected_names;
1173
1174 AXTreeUpdate tree;
1175 tree.root_id = 1;
1176 tree.nodes.resize(11);
1177 tree.nodes[0].id = 1;
1178 tree.nodes[0].child_ids = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
1179
1180 // If the status is EligibleForAnnotation and there's no existing label,
1181 // the name should be the discoverability string.
1182 tree.nodes[1].id = 2;
1183 tree.nodes[1].role = ax::mojom::Role::kImage;
1184 tree.nodes[1].AddStringAttribute(ax::mojom::StringAttribute::kImageAnnotation,
1185 "Annotation");
1186 tree.nodes[1].SetImageAnnotationStatus(
1188 expected_names.push_back(
1189 L"To get missing image descriptions, open the context menu.");
1190
1191 // If the status is EligibleForAnnotation, the discoverability string
1192 // should be appended to the existing name.
1193 tree.nodes[2].id = 3;
1194 tree.nodes[2].role = ax::mojom::Role::kImage;
1195 tree.nodes[2].AddStringAttribute(ax::mojom::StringAttribute::kImageAnnotation,
1196 "Annotation");
1197 tree.nodes[2].SetName("ExistingLabel");
1198 tree.nodes[2].SetImageAnnotationStatus(
1200 expected_names.push_back(
1201 L"ExistingLabel. To get missing image descriptions, open the context "
1202 L"menu.");
1203
1204 // If the status is SilentlyEligibleForAnnotation, the discoverability string
1205 // should not be appended to the existing name.
1206 tree.nodes[3].id = 4;
1207 tree.nodes[3].role = ax::mojom::Role::kImage;
1208 tree.nodes[3].AddStringAttribute(ax::mojom::StringAttribute::kImageAnnotation,
1209 "Annotation");
1210 tree.nodes[3].SetName("ExistingLabel");
1211 tree.nodes[3].SetImageAnnotationStatus(
1213 expected_names.push_back(L"ExistingLabel");
1214
1215 // If the status is IneligibleForAnnotation, nothing should be appended.
1216 tree.nodes[4].id = 5;
1217 tree.nodes[4].role = ax::mojom::Role::kImage;
1218 tree.nodes[4].AddStringAttribute(ax::mojom::StringAttribute::kImageAnnotation,
1219 "Annotation");
1220 tree.nodes[4].SetName("ExistingLabel");
1221 tree.nodes[4].SetImageAnnotationStatus(
1223 expected_names.push_back(L"ExistingLabel");
1224
1225 // If the status is AnnotationPending, pending text should be appended
1226 // to the name.
1227 tree.nodes[5].id = 6;
1228 tree.nodes[5].role = ax::mojom::Role::kImage;
1229 tree.nodes[5].AddStringAttribute(ax::mojom::StringAttribute::kImageAnnotation,
1230 "Annotation");
1231 tree.nodes[5].SetName("ExistingLabel");
1232 tree.nodes[5].SetImageAnnotationStatus(
1234 expected_names.push_back(L"ExistingLabel. Getting description...");
1235
1236 // If the status is AnnotationSucceeded, and there's no annotation,
1237 // nothing should be appended. (Ideally this shouldn't happen.)
1238 tree.nodes[6].id = 7;
1239 tree.nodes[6].role = ax::mojom::Role::kImage;
1240 tree.nodes[6].SetName("ExistingLabel");
1241 tree.nodes[6].SetImageAnnotationStatus(
1243 expected_names.push_back(L"ExistingLabel");
1244
1245 // If the status is AnnotationSucceeded, the annotation should be appended
1246 // to the existing label.
1247 tree.nodes[7].id = 8;
1248 tree.nodes[7].role = ax::mojom::Role::kImage;
1249 tree.nodes[7].AddStringAttribute(ax::mojom::StringAttribute::kImageAnnotation,
1250 "Annotation");
1251 tree.nodes[7].SetName("ExistingLabel");
1252 tree.nodes[7].SetImageAnnotationStatus(
1254 expected_names.push_back(L"ExistingLabel. Annotation");
1255
1256 // If the status is AnnotationEmpty, failure text should be added to the
1257 // name.
1258 tree.nodes[8].id = 9;
1259 tree.nodes[8].role = ax::mojom::Role::kImage;
1260 tree.nodes[8].AddStringAttribute(ax::mojom::StringAttribute::kImageAnnotation,
1261 "Annotation");
1262 tree.nodes[8].SetName("ExistingLabel");
1263 tree.nodes[8].SetImageAnnotationStatus(
1265 expected_names.push_back(L"ExistingLabel. No description available.");
1266
1267 // If the status is AnnotationAdult, appropriate text should be appended
1268 // to the name.
1269 tree.nodes[9].id = 10;
1270 tree.nodes[9].role = ax::mojom::Role::kImage;
1271 tree.nodes[9].AddStringAttribute(ax::mojom::StringAttribute::kImageAnnotation,
1272 "Annotation");
1273 tree.nodes[9].SetName("ExistingLabel");
1274 tree.nodes[9].SetImageAnnotationStatus(
1276 expected_names.push_back(
1277 L"ExistingLabel. Appears to contain adult content. No description "
1278 L"available.");
1279
1280 // If the status is AnnotationProcessFailed, failure text should be added
1281 // to the name.
1282 tree.nodes[10].id = 11;
1283 tree.nodes[10].role = ax::mojom::Role::kImage;
1284 tree.nodes[10].AddStringAttribute(
1286 tree.nodes[10].SetName("ExistingLabel");
1287 tree.nodes[10].SetImageAnnotationStatus(
1289 expected_names.push_back(L"ExistingLabel. No description available.");
1290
1291 // We should have one expected name per child of the root.
1292 ASSERT_EQ(expected_names.size(), tree.nodes[0].child_ids.size());
1293 int child_count = static_cast<int>(expected_names.size());
1294
1295 Init(tree);
1296
1297 ComPtr<IAccessible> root_obj(GetRootIAccessible());
1298
1299 for (int child_index = 0; child_index < child_count; child_index++) {
1300 ComPtr<IDispatch> child_dispatch;
1301 ASSERT_HRESULT_SUCCEEDED(root_obj->get_accChild(
1302 ScopedVariant(child_index + 1), &child_dispatch));
1303 ComPtr<IAccessible> child;
1304 ASSERT_HRESULT_SUCCEEDED(child_dispatch.As(&child));
1305
1307 EXPECT_EQ(S_OK, child->get_accName(SELF, name.Receive()));
1308 EXPECT_STREQ(expected_names[child_index], name.Get());
1309 }
1310}
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ TEST_F() [86/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ComputeUIAControlType   
)

Definition at line 3034 of file ax_platform_node_win_unittest.cc.

3034 {
3036 root.id = 1;
3038
3039 AXNodeData child1;
3040 AXNode::AXID child1_id = 2;
3041 child1.id = child1_id;
3043 root.child_ids.push_back(child1_id);
3044
3045 AXNodeData child2;
3046 AXNode::AXID child2_id = 3;
3047 child2.id = child2_id;
3049 root.child_ids.push_back(child2_id);
3050
3051 AXNodeData child3;
3052 AXNode::AXID child3_id = 4;
3053 child3.id = child3_id;
3055 root.child_ids.push_back(child3_id);
3056
3057 AXNodeData child4;
3058 AXNode::AXID child4_id = 5;
3059 child4.id = child4_id;
3061 root.child_ids.push_back(child4_id);
3062
3063 Init(root, child1, child2, child3, child4);
3064
3066 QueryInterfaceFromNodeId<IRawElementProviderSimple>(child1_id),
3067 UIA_ControlTypePropertyId, int{UIA_TableControlTypeId});
3069 QueryInterfaceFromNodeId<IRawElementProviderSimple>(child2_id),
3070 UIA_ControlTypePropertyId, int{UIA_TableControlTypeId});
3072 QueryInterfaceFromNodeId<IRawElementProviderSimple>(child3_id),
3073 UIA_ControlTypePropertyId, int{UIA_EditControlTypeId});
3075 QueryInterfaceFromNodeId<IRawElementProviderSimple>(child4_id),
3076 UIA_ControlTypePropertyId, int{UIA_EditControlTypeId});
3077}
#define EXPECT_UIA_INT_EQ(node, property_id, expected)
int32_t AXID
Definition: ax_node.h:36

◆ TEST_F() [87/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
GetPatternProviderExpandCollapsePattern   
)

Definition at line 3578 of file ax_platform_node_win_unittest.cc.

3578 {
3580 root.id = 1;
3581
3582 ui::AXNodeData list_box;
3583 ui::AXNodeData list_item;
3584 ui::AXNodeData menu_item;
3585 ui::AXNodeData menu_list_option;
3586 ui::AXNodeData tree_item;
3587 ui::AXNodeData combo_box_grouping;
3588 ui::AXNodeData combo_box_menu_button;
3589 ui::AXNodeData disclosure_triangle;
3590 ui::AXNodeData text_field_with_combo_box;
3591
3592 list_box.id = 2;
3593 list_item.id = 3;
3594 menu_item.id = 4;
3595 menu_list_option.id = 5;
3596 tree_item.id = 6;
3597 combo_box_grouping.id = 7;
3598 combo_box_menu_button.id = 8;
3599 disclosure_triangle.id = 9;
3600 text_field_with_combo_box.id = 10;
3601
3602 root.child_ids.push_back(list_box.id);
3603 root.child_ids.push_back(list_item.id);
3604 root.child_ids.push_back(menu_item.id);
3605 root.child_ids.push_back(menu_list_option.id);
3606 root.child_ids.push_back(tree_item.id);
3607 root.child_ids.push_back(combo_box_grouping.id);
3608 root.child_ids.push_back(combo_box_menu_button.id);
3609 root.child_ids.push_back(disclosure_triangle.id);
3610 root.child_ids.push_back(text_field_with_combo_box.id);
3611
3612 // list_box HasPopup set to false, does not support expand collapse.
3615
3616 // list_item HasPopup set to true, supports expand collapse.
3617 list_item.role = ax::mojom::Role::kListItem;
3619
3620 // menu_item has expanded state and supports expand collapse.
3621 menu_item.role = ax::mojom::Role::kMenuItem;
3623
3624 // menu_list_option has collapsed state and supports expand collapse.
3625 menu_list_option.role = ax::mojom::Role::kMenuListOption;
3626 menu_list_option.AddState(ax::mojom::State::kCollapsed);
3627
3628 // These roles by default supports expand collapse.
3629 tree_item.role = ax::mojom::Role::kTreeItem;
3630 combo_box_grouping.role = ax::mojom::Role::kComboBoxGrouping;
3631 combo_box_menu_button.role = ax::mojom::Role::kComboBoxMenuButton;
3632 disclosure_triangle.role = ax::mojom::Role::kDisclosureTriangle;
3633 text_field_with_combo_box.role = ax::mojom::Role::kTextFieldWithComboBox;
3634
3635 Init(root, list_box, list_item, menu_item, menu_list_option, tree_item,
3636 combo_box_grouping, combo_box_menu_button, disclosure_triangle,
3637 text_field_with_combo_box);
3638
3639 // list_box HasPopup set to false, does not support expand collapse.
3640 ComPtr<IRawElementProviderSimple> raw_element_provider_simple =
3641 GetIRawElementProviderSimpleFromChildIndex(0);
3642 ComPtr<IExpandCollapseProvider> expandcollapse_provider;
3643 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3644 UIA_ExpandCollapsePatternId, &expandcollapse_provider));
3645 EXPECT_EQ(nullptr, expandcollapse_provider.Get());
3646
3647 // list_item HasPopup set to true, supports expand collapse.
3648 raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(1);
3649 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3650 UIA_ExpandCollapsePatternId, &expandcollapse_provider));
3651 EXPECT_NE(nullptr, expandcollapse_provider.Get());
3652
3653 // menu_item has expanded state and supports expand collapse.
3654 raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(2);
3655 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3656 UIA_ExpandCollapsePatternId, &expandcollapse_provider));
3657 EXPECT_NE(nullptr, expandcollapse_provider.Get());
3658
3659 // menu_list_option has collapsed state and supports expand collapse.
3660 raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(3);
3661 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3662 UIA_ExpandCollapsePatternId, &expandcollapse_provider));
3663 EXPECT_NE(nullptr, expandcollapse_provider.Get());
3664
3665 // tree_item by default supports expand collapse.
3666 raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(4);
3667 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3668 UIA_ExpandCollapsePatternId, &expandcollapse_provider));
3669 EXPECT_NE(nullptr, expandcollapse_provider.Get());
3670
3671 // combo_box_grouping by default supports expand collapse.
3672 raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(5);
3673 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3674 UIA_ExpandCollapsePatternId, &expandcollapse_provider));
3675 EXPECT_NE(nullptr, expandcollapse_provider.Get());
3676
3677 // combo_box_menu_button by default supports expand collapse.
3678 raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(6);
3679 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3680 UIA_ExpandCollapsePatternId, &expandcollapse_provider));
3681 EXPECT_NE(nullptr, expandcollapse_provider.Get());
3682
3683 // disclosure_triangle by default supports expand collapse.
3684 raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(7);
3685 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3686 UIA_ExpandCollapsePatternId, &expandcollapse_provider));
3687 EXPECT_NE(nullptr, expandcollapse_provider.Get());
3688
3689 // text_field_with_combo_box by default supports expand collapse.
3690 raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(8);
3691 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3692 UIA_ExpandCollapsePatternId, &expandcollapse_provider));
3693 EXPECT_NE(nullptr, expandcollapse_provider.Get());
3694}

◆ TEST_F() [88/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
GetPatternProviderInvokePattern   
)

Definition at line 3696 of file ax_platform_node_win_unittest.cc.

3696 {
3698 root.id = 1;
3699
3701 ui::AXNodeData generic_container;
3702 ui::AXNodeData combo_box_grouping;
3703 ui::AXNodeData check_box;
3704
3705 link.id = 2;
3706 generic_container.id = 3;
3707 combo_box_grouping.id = 4;
3708 check_box.id = 5;
3709
3710 root.child_ids.push_back(link.id);
3711 root.child_ids.push_back(generic_container.id);
3712 root.child_ids.push_back(combo_box_grouping.id);
3713 root.child_ids.push_back(check_box.id);
3714
3715 // Role link is clickable and neither supports expand collapse nor supports
3716 // toggle. It should support invoke pattern.
3718
3719 // Role generic container is not clickable. It should not support invoke
3720 // pattern.
3721 generic_container.role = ax::mojom::Role::kGenericContainer;
3722
3723 // Role combo box grouping supports expand collapse. It should not support
3724 // invoke pattern.
3725 combo_box_grouping.role = ax::mojom::Role::kComboBoxGrouping;
3726
3727 // Role check box supports toggle. It should not support invoke pattern.
3728 check_box.role = ax::mojom::Role::kCheckBox;
3729
3730 Init(root, link, generic_container, combo_box_grouping, check_box);
3731
3732 // Role link is clickable and neither supports expand collapse nor supports
3733 // toggle. It should support invoke pattern.
3734 ComPtr<IRawElementProviderSimple> raw_element_provider_simple =
3735 GetIRawElementProviderSimpleFromChildIndex(0);
3736 ComPtr<IInvokeProvider> invoke_provider;
3737 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3738 UIA_InvokePatternId, &invoke_provider));
3739 EXPECT_NE(nullptr, invoke_provider.Get());
3740
3741 // Role generic container is not clickable. It should not support invoke
3742 // pattern.
3743 raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(1);
3744 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3745 UIA_InvokePatternId, &invoke_provider));
3746 EXPECT_EQ(nullptr, invoke_provider.Get());
3747
3748 // Role combo box grouping supports expand collapse. It should not support
3749 // invoke pattern.
3750 raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(2);
3751 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3752 UIA_InvokePatternId, &invoke_provider));
3753 EXPECT_EQ(nullptr, invoke_provider.Get());
3754
3755 // Role check box supports toggle. It should not support invoke pattern.
3756 raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(3);
3757 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3758 UIA_InvokePatternId, &invoke_provider));
3759 EXPECT_EQ(nullptr, invoke_provider.Get());
3760}
def link(from_root, to_root)
Definition: dart_pkg.py:44

◆ TEST_F() [89/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
GetPatternProviderSupportedPatterns   
)

Definition at line 3417 of file ax_platform_node_win_unittest.cc.

3417 {
3418 constexpr AXNode::AXID root_id = 1;
3419 constexpr AXNode::AXID text_field_with_combo_box_id = 2;
3420 constexpr AXNode::AXID meter_id = 3;
3421 constexpr AXNode::AXID group_with_scroll_id = 4;
3422 constexpr AXNode::AXID checkbox_id = 5;
3423 constexpr AXNode::AXID link_id = 6;
3424 constexpr AXNode::AXID table_without_header_id = 7;
3425 constexpr AXNode::AXID table_without_header_cell_id = 8;
3426 constexpr AXNode::AXID table_with_header_id = 9;
3427 constexpr AXNode::AXID table_with_header_row_1_id = 10;
3428 constexpr AXNode::AXID table_with_header_column_header_id = 11;
3429 constexpr AXNode::AXID table_with_header_row_2_id = 12;
3430 constexpr AXNode::AXID table_with_header_cell_id = 13;
3431 constexpr AXNode::AXID grid_without_header_id = 14;
3432 constexpr AXNode::AXID grid_without_header_cell_id = 15;
3433 constexpr AXNode::AXID grid_with_header_id = 16;
3434 constexpr AXNode::AXID grid_with_header_row_1_id = 17;
3435 constexpr AXNode::AXID grid_with_header_column_header_id = 18;
3436 constexpr AXNode::AXID grid_with_header_row_2_id = 19;
3437 constexpr AXNode::AXID grid_with_header_cell_id = 20;
3438
3440 update.tree_data.tree_id = ui::AXTreeID::CreateNewAXTreeID();
3441 update.has_tree_data = true;
3442 update.root_id = root_id;
3443 update.nodes.resize(20);
3444 update.nodes[0].id = root_id;
3445 update.nodes[0].role = ax::mojom::Role::kRootWebArea;
3446 update.nodes[0].child_ids = {text_field_with_combo_box_id,
3447 meter_id,
3448 group_with_scroll_id,
3449 checkbox_id,
3450 link_id,
3451 table_without_header_id,
3452 table_with_header_id,
3453 grid_without_header_id,
3454 grid_with_header_id};
3455 update.nodes[1].id = text_field_with_combo_box_id;
3457 update.nodes[2].id = meter_id;
3458 update.nodes[2].role = ax::mojom::Role::kMeter;
3459 update.nodes[3].id = group_with_scroll_id;
3460 update.nodes[3].role = ax::mojom::Role::kGroup;
3461 update.nodes[3].AddIntAttribute(ax::mojom::IntAttribute::kScrollXMin, 10);
3462 update.nodes[3].AddIntAttribute(ax::mojom::IntAttribute::kScrollXMax, 10);
3463 update.nodes[3].AddIntAttribute(ax::mojom::IntAttribute::kScrollX, 10);
3464 update.nodes[4].id = checkbox_id;
3465 update.nodes[4].role = ax::mojom::Role::kCheckBox;
3466 update.nodes[5].id = link_id;
3467 update.nodes[5].role = ax::mojom::Role::kLink;
3468 update.nodes[6].id = table_without_header_id;
3469 update.nodes[6].role = ax::mojom::Role::kTable;
3470 update.nodes[6].child_ids = {table_without_header_cell_id};
3471 update.nodes[7].id = table_without_header_cell_id;
3472 update.nodes[7].role = ax::mojom::Role::kCell;
3473 update.nodes[8].id = table_with_header_id;
3474 update.nodes[8].role = ax::mojom::Role::kTable;
3475 update.nodes[8].child_ids = {table_with_header_row_1_id,
3476 table_with_header_row_2_id};
3477 update.nodes[9].id = table_with_header_row_1_id;
3478 update.nodes[9].role = ax::mojom::Role::kRow;
3479 update.nodes[9].child_ids = {table_with_header_column_header_id};
3480 update.nodes[10].id = table_with_header_column_header_id;
3481 update.nodes[10].role = ax::mojom::Role::kColumnHeader;
3482 update.nodes[11].id = table_with_header_row_2_id;
3483 update.nodes[11].role = ax::mojom::Role::kRow;
3484 update.nodes[11].child_ids = {table_with_header_cell_id};
3485 update.nodes[12].id = table_with_header_cell_id;
3486 update.nodes[12].role = ax::mojom::Role::kCell;
3487 update.nodes[13].id = grid_without_header_id;
3488 update.nodes[13].role = ax::mojom::Role::kGrid;
3489 update.nodes[13].child_ids = {grid_without_header_cell_id};
3490 update.nodes[14].id = grid_without_header_cell_id;
3491 update.nodes[14].role = ax::mojom::Role::kCell;
3492 update.nodes[14].AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, false);
3493 update.nodes[15].id = grid_with_header_id;
3494 update.nodes[15].role = ax::mojom::Role::kGrid;
3495 update.nodes[15].child_ids = {grid_with_header_row_1_id,
3496 grid_with_header_row_2_id};
3497 update.nodes[16].id = grid_with_header_row_1_id;
3498 update.nodes[16].role = ax::mojom::Role::kRow;
3499 update.nodes[16].child_ids = {grid_with_header_column_header_id};
3500 update.nodes[17].id = grid_with_header_column_header_id;
3501 update.nodes[17].role = ax::mojom::Role::kColumnHeader;
3502 update.nodes[17].AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, false);
3503 update.nodes[18].id = grid_with_header_row_2_id;
3504 update.nodes[18].role = ax::mojom::Role::kRow;
3505 update.nodes[18].child_ids = {grid_with_header_cell_id};
3506 update.nodes[19].id = grid_with_header_cell_id;
3507 update.nodes[19].role = ax::mojom::Role::kCell;
3508 update.nodes[19].AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, false);
3509
3510 Init(update);
3511
3512 EXPECT_EQ(PatternSet({UIA_ScrollItemPatternId, UIA_TextPatternId,
3513 UIA_TextEditPatternId}),
3514 GetSupportedPatternsFromNodeId(root_id));
3515
3516 EXPECT_EQ(PatternSet({UIA_ScrollItemPatternId, UIA_ValuePatternId,
3517 UIA_ExpandCollapsePatternId, UIA_TextPatternId,
3518 UIA_TextEditPatternId}),
3519 GetSupportedPatternsFromNodeId(text_field_with_combo_box_id));
3520
3521 EXPECT_EQ(PatternSet({UIA_ScrollItemPatternId, UIA_ValuePatternId,
3522 UIA_RangeValuePatternId}),
3523 GetSupportedPatternsFromNodeId(meter_id));
3524
3525 EXPECT_EQ(PatternSet({UIA_ScrollItemPatternId, UIA_ScrollPatternId}),
3526 GetSupportedPatternsFromNodeId(group_with_scroll_id));
3527
3528 EXPECT_EQ(PatternSet({UIA_ScrollItemPatternId, UIA_ValuePatternId,
3529 UIA_TogglePatternId}),
3530 GetSupportedPatternsFromNodeId(checkbox_id));
3531
3532 EXPECT_EQ(PatternSet({UIA_ScrollItemPatternId, UIA_ValuePatternId,
3533 UIA_InvokePatternId}),
3534 GetSupportedPatternsFromNodeId(link_id));
3535
3536 EXPECT_EQ(PatternSet({UIA_ScrollItemPatternId, UIA_GridPatternId}),
3537 GetSupportedPatternsFromNodeId(table_without_header_id));
3538
3539 EXPECT_EQ(PatternSet({UIA_ScrollItemPatternId, UIA_GridItemPatternId}),
3540 GetSupportedPatternsFromNodeId(table_without_header_cell_id));
3541
3542 EXPECT_EQ(PatternSet({UIA_ScrollItemPatternId, UIA_GridPatternId,
3543 UIA_TablePatternId}),
3544 GetSupportedPatternsFromNodeId(table_with_header_id));
3545
3546 EXPECT_EQ(PatternSet({UIA_ScrollItemPatternId, UIA_GridItemPatternId,
3547 UIA_TableItemPatternId}),
3548 GetSupportedPatternsFromNodeId(table_with_header_column_header_id));
3549
3550 EXPECT_EQ(PatternSet({UIA_ScrollItemPatternId, UIA_GridItemPatternId,
3551 UIA_TableItemPatternId}),
3552 GetSupportedPatternsFromNodeId(table_with_header_cell_id));
3553
3554 EXPECT_EQ(PatternSet({UIA_ScrollItemPatternId, UIA_ValuePatternId,
3555 UIA_SelectionPatternId, UIA_GridPatternId}),
3556 GetSupportedPatternsFromNodeId(grid_without_header_id));
3557
3558 EXPECT_EQ(PatternSet({UIA_ScrollItemPatternId, UIA_ValuePatternId,
3559 UIA_SelectionItemPatternId, UIA_GridItemPatternId}),
3560 GetSupportedPatternsFromNodeId(grid_without_header_cell_id));
3561
3562 EXPECT_EQ(PatternSet({UIA_ScrollItemPatternId, UIA_ValuePatternId,
3563 UIA_SelectionPatternId, UIA_GridPatternId,
3564 UIA_TablePatternId}),
3565 GetSupportedPatternsFromNodeId(grid_with_header_id));
3566
3567 EXPECT_EQ(PatternSet({UIA_ScrollItemPatternId, UIA_ValuePatternId,
3568 UIA_GridItemPatternId, UIA_TableItemPatternId,
3569 UIA_SelectionItemPatternId}),
3570 GetSupportedPatternsFromNodeId(grid_with_header_column_header_id));
3571
3572 EXPECT_EQ(PatternSet({UIA_ScrollItemPatternId, UIA_ValuePatternId,
3573 UIA_GridItemPatternId, UIA_TableItemPatternId,
3574 UIA_SelectionItemPatternId}),
3575 GetSupportedPatternsFromNodeId(grid_with_header_cell_id));
3576}

◆ TEST_F() [90/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
GetPropertyValue_HelpText   
)

Definition at line 2355 of file ax_platform_node_win_unittest.cc.

2355 {
2357 root.id = 1;
2359
2360 // Test Placeholder StringAttribute is exposed
2361 AXNodeData input1;
2362 input1.id = 2;
2364 input1.SetName("name-from-title");
2366 static_cast<int>(ax::mojom::NameFrom::kTitle));
2368 "placeholder");
2369 root.child_ids.push_back(input1.id);
2370
2371 // Test NameFrom Title is exposed
2372 AXNodeData input2;
2373 input2.id = 3;
2375 input2.SetName("name-from-title");
2377 static_cast<int>(ax::mojom::NameFrom::kTitle));
2378 root.child_ids.push_back(input2.id);
2379
2380 // Test NameFrom Placeholder is exposed
2381 AXNodeData input3;
2382 input3.id = 4;
2384 input3.SetName("name-from-placeholder");
2386 static_cast<int>(ax::mojom::NameFrom::kPlaceholder));
2387 root.child_ids.push_back(input3.id);
2388
2389 // Test Title StringAttribute is exposed
2390 AXNodeData input4;
2391 input4.id = 5;
2393 input4.SetName("name-from-attribute");
2395 static_cast<int>(ax::mojom::NameFrom::kAttribute));
2397 root.child_ids.push_back(input4.id);
2398
2399 // Test NameFrom (other), without explicit
2400 // Title / Placeholder StringAttribute is not exposed
2401 AXNodeData input5;
2402 input5.id = 6;
2404 input5.SetName("name-from-attribute");
2406 static_cast<int>(ax::mojom::NameFrom::kAttribute));
2407 root.child_ids.push_back(input5.id);
2408
2409 Init(root, input1, input2, input3, input4, input5);
2410
2411 auto* root_node = GetRootAsAXNode();
2412 EXPECT_UIA_BSTR_EQ(QueryInterfaceFromNode<IRawElementProviderSimple>(
2413 root_node->children()[0]),
2414 UIA_HelpTextPropertyId, L"placeholder");
2415 EXPECT_UIA_BSTR_EQ(QueryInterfaceFromNode<IRawElementProviderSimple>(
2416 root_node->children()[1]),
2417 UIA_HelpTextPropertyId, L"name-from-title");
2418 EXPECT_UIA_BSTR_EQ(QueryInterfaceFromNode<IRawElementProviderSimple>(
2419 root_node->children()[2]),
2420 UIA_HelpTextPropertyId, L"name-from-placeholder");
2421 EXPECT_UIA_BSTR_EQ(QueryInterfaceFromNode<IRawElementProviderSimple>(
2422 root_node->children()[3]),
2423 UIA_HelpTextPropertyId, L"tooltip");
2424 EXPECT_UIA_VALUE_EQ(QueryInterfaceFromNode<IRawElementProviderSimple>(
2425 root_node->children()[4]),
2426 UIA_HelpTextPropertyId, ScopedVariant::kEmptyVariant);
2427}
#define EXPECT_UIA_VALUE_EQ(node, property_id, expectedVariant)
#define EXPECT_UIA_BSTR_EQ(node, property_id, expected)

◆ TEST_F() [91/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
GetPropertyValue_IsControlElement   
)

Definition at line 2463 of file ax_platform_node_win_unittest.cc.

2463 {
2466 update.tree_data.tree_id = tree_id;
2467 update.has_tree_data = true;
2468 update.root_id = 1;
2469 update.nodes.resize(17);
2470 update.nodes[0].id = 1;
2471 update.nodes[0].role = ax::mojom::Role::kRootWebArea;
2472 update.nodes[0].child_ids = {2, 4, 6, 7, 8, 9, 10,
2473 11, 12, 13, 14, 15, 16, 17};
2474 update.nodes[1].id = 2;
2475 update.nodes[1].role = ax::mojom::Role::kButton;
2476 update.nodes[1].child_ids = {3};
2477 update.nodes[2].id = 3;
2478 update.nodes[2].role = ax::mojom::Role::kStaticText;
2479 update.nodes[2].SetName("some text");
2480 update.nodes[3].id = 4;
2482 update.nodes[3].child_ids = {5};
2483 update.nodes[4].id = 5;
2484 update.nodes[4].role = ax::mojom::Role::kStaticText;
2485 update.nodes[4].SetName("more text");
2486 update.nodes[5].id = 6;
2487 update.nodes[5].role = ax::mojom::Role::kTable;
2488 update.nodes[6].id = 7;
2489 update.nodes[6].role = ax::mojom::Role::kList;
2490 update.nodes[7].id = 8;
2491 update.nodes[7].role = ax::mojom::Role::kForm;
2492 update.nodes[8].id = 9;
2493 update.nodes[8].role = ax::mojom::Role::kImage;
2494 update.nodes[9].id = 10;
2495 update.nodes[9].role = ax::mojom::Role::kImage;
2496 update.nodes[9].SetNameExplicitlyEmpty();
2497 update.nodes[10].id = 11;
2498 update.nodes[10].role = ax::mojom::Role::kArticle;
2499 update.nodes[11].id = 12;
2501 update.nodes[11].AddBoolAttribute(ax::mojom::BoolAttribute::kHasAriaAttribute,
2502 true);
2503 update.nodes[12].id = 13;
2505 update.nodes[12].AddBoolAttribute(ax::mojom::BoolAttribute::kEditableRoot,
2506 true);
2507 update.nodes[13].id = 14;
2509 update.nodes[13].SetName("name");
2510 update.nodes[14].id = 15;
2512 update.nodes[14].SetDescription("description");
2513 update.nodes[15].id = 16;
2515 update.nodes[15].AddState(ax::mojom::State::kFocusable);
2516 update.nodes[16].id = 17;
2517 update.nodes[16].role = ax::mojom::Role::kForm;
2518 update.nodes[16].SetName("name");
2519
2520 Init(update);
2521 TestAXNodeWrapper::SetGlobalIsWebContent(true);
2522
2523 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromTree(tree_id, 2),
2524 UIA_IsControlElementPropertyId, true);
2525 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromTree(tree_id, 3),
2526 UIA_IsControlElementPropertyId, false);
2527 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromTree(tree_id, 4),
2528 UIA_IsControlElementPropertyId, false);
2529 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromTree(tree_id, 5),
2530 UIA_IsControlElementPropertyId, true);
2531 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromTree(tree_id, 6),
2532 UIA_IsControlElementPropertyId, true);
2533 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromTree(tree_id, 7),
2534 UIA_IsControlElementPropertyId, true);
2535 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromTree(tree_id, 8),
2536 UIA_IsControlElementPropertyId, false);
2537 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromTree(tree_id, 9),
2538 UIA_IsControlElementPropertyId, true);
2539 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromTree(tree_id, 10),
2540 UIA_IsControlElementPropertyId, false);
2541 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromTree(tree_id, 11),
2542 UIA_IsControlElementPropertyId, true);
2543 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromTree(tree_id, 12),
2544 UIA_IsControlElementPropertyId, true);
2545 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromTree(tree_id, 13),
2546 UIA_IsControlElementPropertyId, true);
2547 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromTree(tree_id, 14),
2548 UIA_IsControlElementPropertyId, true);
2549 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromTree(tree_id, 15),
2550 UIA_IsControlElementPropertyId, true);
2551 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromTree(tree_id, 16),
2552 UIA_IsControlElementPropertyId, true);
2553 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromTree(tree_id, 17),
2554 UIA_IsControlElementPropertyId, true);
2555}
#define EXPECT_UIA_BOOL_EQ(node, property_id, expected)

◆ TEST_F() [92/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
GetPropertyValue_LabeledByTest   
)

Definition at line 2230 of file ax_platform_node_win_unittest.cc.

2230 {
2231 // ++1 root
2232 // ++++2 kGenericContainer LabeledBy 3
2233 // ++++++3 kStaticText "Hello"
2234 // ++++4 kGenericContainer LabeledBy 5
2235 // ++++++5 kGenericContainer
2236 // ++++++++6 kStaticText "3.14"
2237 // ++++7 kAlert LabeledBy 6
2238 AXNodeData root_1;
2239 AXNodeData gc_2;
2240 AXNodeData static_text_3;
2241 AXNodeData gc_4;
2242 AXNodeData gc_5;
2243 AXNodeData static_text_6;
2244 AXNodeData alert_7;
2245
2246 root_1.id = 1;
2247 gc_2.id = 2;
2248 static_text_3.id = 3;
2249 gc_4.id = 4;
2250 gc_5.id = 5;
2251 static_text_6.id = 6;
2252 alert_7.id = 7;
2253
2255 root_1.child_ids = {gc_2.id, gc_4.id, alert_7.id};
2256
2259 {static_text_3.id});
2260 gc_2.child_ids = {static_text_3.id};
2261
2262 static_text_3.role = ax::mojom::Role::kStaticText;
2263 static_text_3.SetName("Hello");
2264
2267 {gc_5.id});
2268 gc_4.child_ids = {gc_5.id};
2269
2271 gc_5.child_ids = {static_text_6.id};
2272
2273 static_text_6.role = ax::mojom::Role::kStaticText;
2274 static_text_6.SetName("3.14");
2275
2276 alert_7.role = ax::mojom::Role::kAlert;
2278 {static_text_6.id});
2279
2280 Init(root_1, gc_2, static_text_3, gc_4, gc_5, static_text_6, alert_7);
2281
2282 AXNode* root_node = GetRootAsAXNode();
2283 AXNode* gc_2_node = root_node->children()[0];
2284 AXNode* static_text_3_node = gc_2_node->children()[0];
2285 AXNode* gc_4_node = root_node->children()[1];
2286 AXNode* static_text_6_node = gc_4_node->children()[0]->children()[0];
2287 AXNode* alert_7_node = root_node->children()[2];
2288
2289 // Case 1: |gc_2| is labeled by |static_text_3|.
2290
2291 ComPtr<IRawElementProviderSimple> gc_2_provider =
2292 GetIRawElementProviderSimpleFromTree(gc_2_node->tree()->GetAXTreeID(),
2293 gc_2_node->id());
2294 ScopedVariant property_value;
2295 EXPECT_EQ(S_OK, gc_2_provider->GetPropertyValue(UIA_LabeledByPropertyId,
2296 property_value.Receive()));
2297 ASSERT_EQ(property_value.type(), VT_UNKNOWN);
2298 ComPtr<IRawElementProviderSimple> static_text_3_provider;
2299 EXPECT_EQ(S_OK, property_value.ptr()->punkVal->QueryInterface(
2300 IID_PPV_ARGS(&static_text_3_provider)));
2301 EXPECT_UIA_BSTR_EQ(static_text_3_provider, UIA_NamePropertyId, L"Hello");
2302
2303 // Case 2: |gc_4| is labeled by |gc_5| and should return the first static text
2304 // child of that node, which is |static_text_6|.
2305
2306 ComPtr<IRawElementProviderSimple> gc_4_provider =
2307 GetIRawElementProviderSimpleFromTree(gc_4_node->tree()->GetAXTreeID(),
2308 gc_4_node->id());
2309 property_value.Reset();
2310 EXPECT_EQ(S_OK, gc_4_provider->GetPropertyValue(UIA_LabeledByPropertyId,
2311 property_value.Receive()));
2312 ASSERT_EQ(property_value.type(), VT_UNKNOWN);
2313 ComPtr<IRawElementProviderSimple> static_text_6_provider;
2314 EXPECT_EQ(S_OK, property_value.ptr()->punkVal->QueryInterface(
2315 IID_PPV_ARGS(&static_text_6_provider)));
2316 EXPECT_UIA_BSTR_EQ(static_text_6_provider, UIA_NamePropertyId, L"3.14");
2317
2318 // Case 3: Some UIA control types always expect an empty value for this
2319 // property. The role kAlert corresponds to UIA_TextControlTypeId, which
2320 // always expects an empty value. |alert_7| is marked as labeled by
2321 // |static_text_6|, but shouldn't expose it to the UIA_LabeledByPropertyId.
2322
2323 ComPtr<IRawElementProviderSimple> alert_7_provider =
2324 GetIRawElementProviderSimpleFromTree(alert_7_node->tree()->GetAXTreeID(),
2325 alert_7_node->id());
2326 property_value.Reset();
2327 EXPECT_EQ(S_OK, alert_7_provider->GetPropertyValue(UIA_LabeledByPropertyId,
2328 property_value.Receive()));
2329 ASSERT_EQ(property_value.type(), VT_EMPTY);
2330
2331 // Remove the referenced nodes' native event targets and verify it's no longer
2332 // returned.
2333
2334 // Case 1.
2335 TestAXNodeWrapper* static_text_3_node_wrapper =
2336 TestAXNodeWrapper::GetOrCreate(GetTree(), static_text_3_node);
2337 static_text_3_node_wrapper->ResetNativeEventTarget();
2338
2339 property_value.Reset();
2340 EXPECT_EQ(S_OK, gc_2_provider->GetPropertyValue(UIA_LabeledByPropertyId,
2341 property_value.Receive()));
2342 EXPECT_EQ(property_value.type(), VT_EMPTY);
2343
2344 // Case 2.
2345 TestAXNodeWrapper* static_text_6_node_wrapper =
2346 TestAXNodeWrapper::GetOrCreate(GetTree(), static_text_6_node);
2347 static_text_6_node_wrapper->ResetNativeEventTarget();
2348
2349 property_value.Reset();
2350 EXPECT_EQ(S_OK, gc_4_provider->GetPropertyValue(UIA_LabeledByPropertyId,
2351 property_value.Receive()));
2352 EXPECT_EQ(property_value.type(), VT_EMPTY);
2353}

◆ TEST_F() [93/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
GetPropertyValue_LocalizedControlType   
)

Definition at line 2429 of file ax_platform_node_win_unittest.cc.

2429 {
2432 root.id = 1;
2434 "root role description");
2435
2436 AXNodeData child1;
2437 child1.id = 2;
2440 "child1 role description");
2441 root.child_ids.push_back(2);
2442
2443 AXNodeData child2;
2444 child2.id = 3;
2446 root.child_ids.push_back(3);
2447
2448 Init(root, child1, child2);
2449
2450 ComPtr<IRawElementProviderSimple> root_node =
2451 GetRootIRawElementProviderSimple();
2452 EXPECT_UIA_BSTR_EQ(root_node, UIA_LocalizedControlTypePropertyId,
2453 L"root role description");
2454 EXPECT_UIA_BSTR_EQ(QueryInterfaceFromNode<IRawElementProviderSimple>(
2455 GetRootAsAXNode()->children()[0]),
2456 UIA_LocalizedControlTypePropertyId,
2457 L"child1 role description");
2458 EXPECT_UIA_BSTR_EQ(QueryInterfaceFromNode<IRawElementProviderSimple>(
2459 GetRootAsAXNode()->children()[1]),
2460 UIA_LocalizedControlTypePropertyId, L"search box");
2461}

◆ TEST_F() [94/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleAccValue   
)

Definition at line 556 of file ax_platform_node_win_unittest.cc.

556 {
558 root.id = 1;
560 root.AddStringAttribute(ax::mojom::StringAttribute::kValue, "Value");
561 Init(root);
562
563 ComPtr<IAccessible> root_obj(GetRootIAccessible());
565 EXPECT_EQ(S_OK, root_obj->get_accValue(SELF, value.Receive()));
566 EXPECT_STREQ(L"Value", value.Get());
567
568 EXPECT_EQ(E_INVALIDARG, root_obj->get_accValue(SELF, nullptr));
569 ScopedVariant bad_id(999);
571 EXPECT_EQ(E_INVALIDARG, root_obj->get_accValue(bad_id, v2.Receive()));
572}
Vec2Value v2

◆ TEST_F() [95/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleChildAndParent   
)

Definition at line 994 of file ax_platform_node_win_unittest.cc.

994 {
996 root.id = 1;
997 root.child_ids.push_back(2);
998 root.child_ids.push_back(3);
999
1000 AXNodeData button;
1002 button.id = 2;
1003
1004 AXNodeData checkbox;
1006 checkbox.id = 3;
1007
1008 Init(root, button, checkbox);
1009 AXNode* button_node = GetRootAsAXNode()->children()[0];
1010 AXNode* checkbox_node = GetRootAsAXNode()->children()[1];
1011 ComPtr<IAccessible> root_iaccessible(GetRootIAccessible());
1012 ComPtr<IAccessible> button_iaccessible(IAccessibleFromNode(button_node));
1013 ComPtr<IAccessible> checkbox_iaccessible(IAccessibleFromNode(checkbox_node));
1014
1015 LONG child_count;
1016 EXPECT_EQ(S_OK, root_iaccessible->get_accChildCount(&child_count));
1017 EXPECT_EQ(2L, child_count);
1018 EXPECT_EQ(S_OK, button_iaccessible->get_accChildCount(&child_count));
1019 EXPECT_EQ(0L, child_count);
1020 EXPECT_EQ(S_OK, checkbox_iaccessible->get_accChildCount(&child_count));
1021 EXPECT_EQ(0L, child_count);
1022
1023 {
1024 ComPtr<IDispatch> result;
1025 EXPECT_EQ(S_OK, root_iaccessible->get_accChild(SELF, &result));
1026 EXPECT_EQ(result.Get(), root_iaccessible.Get());
1027 }
1028
1029 {
1030 ComPtr<IDispatch> result;
1031 ScopedVariant child1(1);
1032 EXPECT_EQ(S_OK, root_iaccessible->get_accChild(child1, &result));
1033 EXPECT_EQ(result.Get(), button_iaccessible.Get());
1034 }
1035
1036 {
1037 ComPtr<IDispatch> result;
1038 ScopedVariant child2(2);
1039 EXPECT_EQ(S_OK, root_iaccessible->get_accChild(child2, &result));
1040 EXPECT_EQ(result.Get(), checkbox_iaccessible.Get());
1041 }
1042
1043 {
1044 // Asking for child id 3 should fail.
1045 ComPtr<IDispatch> result;
1046 ScopedVariant child3(3);
1047 EXPECT_EQ(E_INVALIDARG, root_iaccessible->get_accChild(child3, &result));
1048 }
1049
1050 // Now check parents.
1051 {
1052 ComPtr<IDispatch> result;
1053 EXPECT_EQ(S_OK, button_iaccessible->get_accParent(&result));
1054 EXPECT_EQ(result.Get(), root_iaccessible.Get());
1055 }
1056
1057 {
1058 ComPtr<IDispatch> result;
1059 EXPECT_EQ(S_OK, checkbox_iaccessible->get_accParent(&result));
1060 EXPECT_EQ(result.Get(), root_iaccessible.Get());
1061 }
1062
1063 {
1064 ComPtr<IDispatch> result;
1065 EXPECT_EQ(S_FALSE, root_iaccessible->get_accParent(&result));
1066 }
1067}

◆ TEST_F() [96/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleDescription   
)

Definition at line 538 of file ax_platform_node_win_unittest.cc.

538 {
540 root.id = 1;
542 "Description");
543 Init(root);
544
545 ComPtr<IAccessible> root_obj(GetRootIAccessible());
546 ScopedBstr description;
547 EXPECT_EQ(S_OK, root_obj->get_accDescription(SELF, description.Receive()));
548 EXPECT_STREQ(L"Description", description.Get());
549
550 EXPECT_EQ(E_INVALIDARG, root_obj->get_accDescription(SELF, nullptr));
551 ScopedVariant bad_id(999);
552 ScopedBstr d2;
553 EXPECT_EQ(E_INVALIDARG, root_obj->get_accDescription(bad_id, d2.Receive()));
554}

◆ TEST_F() [97/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleDetachedObject   
)

Definition at line 432 of file ax_platform_node_win_unittest.cc.

432 {
434 root.id = 1;
436 root.SetName("Name");
437 Init(root);
438
439 ComPtr<IAccessible> root_obj(GetRootIAccessible());
441 EXPECT_EQ(S_OK, root_obj->get_accName(SELF, name.Receive()));
442 EXPECT_STREQ(L"Name", name.Get());
443
444 // Create an empty tree.
445 SetTree(std::make_unique<AXTree>());
446 ScopedBstr name2;
447 EXPECT_EQ(E_FAIL, root_obj->get_accName(SELF, name2.Receive()));
448}

◆ TEST_F() [98/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleHitTest   
)

Definition at line 450 of file ax_platform_node_win_unittest.cc.

450 {
452 root.id = 1;
453 root.relative_bounds.bounds = gfx::RectF(0, 0, 40, 40);
454
455 AXNodeData node1;
456 node1.id = 2;
458 node1.relative_bounds.bounds = gfx::RectF(0, 0, 10, 10);
459 node1.SetName("Name1");
460 root.child_ids.push_back(node1.id);
461
462 AXNodeData node2;
463 node2.id = 3;
465 node2.relative_bounds.bounds = gfx::RectF(20, 20, 20, 20);
466 node2.SetName("Name2");
467 root.child_ids.push_back(node2.id);
468
469 Init(root, node1, node2);
470
471 ComPtr<IAccessible> root_obj(GetRootIAccessible());
472
473 // This is way outside of the root node.
474 ScopedVariant obj_1;
475 EXPECT_EQ(S_FALSE, root_obj->accHitTest(50, 50, obj_1.Receive()));
476 EXPECT_EQ(VT_EMPTY, obj_1.type());
477
478 // This is directly on node 1.
479 EXPECT_EQ(S_OK, root_obj->accHitTest(5, 5, obj_1.Receive()));
480 ASSERT_NE(nullptr, obj_1.ptr());
481 CheckVariantHasName(obj_1, L"Name1");
482
483 // This is directly on node 2 with a scale factor of 1.5.
484 ScopedVariant obj_2;
485 std::unique_ptr<base::AutoReset<float>> scale_factor_reset =
486 TestAXNodeWrapper::SetScaleFactor(1.5);
487 EXPECT_EQ(S_OK, root_obj->accHitTest(38, 38, obj_2.Receive()));
488 ASSERT_NE(nullptr, obj_2.ptr());
489 CheckVariantHasName(obj_2, L"Name2");
490}

◆ TEST_F() [99/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleHitTestDoesNotLoopForever   
)

Definition at line 492 of file ax_platform_node_win_unittest.cc.

492 {
494 root.id = 1;
495 root.relative_bounds.bounds = gfx::RectF(0, 0, 40, 40);
496
497 AXNodeData node1;
498 node1.id = 2;
500 node1.relative_bounds.bounds = gfx::RectF(0, 0, 10, 10);
501 node1.SetName("Name1");
502 root.child_ids.push_back(node1.id);
503
504 Init(root, node1);
505
506 // Set up the endless loop.
507 TestAXNodeWrapper::SetHitTestResult(1, 2);
508 TestAXNodeWrapper::SetHitTestResult(2, 1);
509
510 // Hit testing on the root returns the child. Hit testing on the
511 // child returns the root, but that should be rejected rather than
512 // looping endlessly.
513 ComPtr<IAccessible> root_obj(GetRootIAccessible());
514 ScopedVariant obj_1;
515 EXPECT_EQ(S_OK, root_obj->accHitTest(5, 5, obj_1.Receive()));
516 ASSERT_NE(nullptr, obj_1.ptr());
517 CheckVariantHasName(obj_1, L"Name1");
518}

◆ TEST_F() [100/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleLocation   
)

Definition at line 962 of file ax_platform_node_win_unittest.cc.

962 {
964 root.id = 1;
965 root.relative_bounds.bounds = gfx::RectF(10, 40, 800, 600);
966 Init(root);
967
968 TestAXNodeWrapper::SetGlobalCoordinateOffset(gfx::Vector2d(100, 200));
969
970 LONG x_left, y_top, width, height;
971 EXPECT_EQ(S_OK, GetRootIAccessible()->accLocation(&x_left, &y_top, &width,
972 &height, SELF));
973 EXPECT_EQ(110, x_left);
974 EXPECT_EQ(240, y_top);
975 EXPECT_EQ(800, width);
976 EXPECT_EQ(600, height);
977
978 EXPECT_EQ(E_INVALIDARG, GetRootIAccessible()->accLocation(
979 nullptr, &y_top, &width, &height, SELF));
980 EXPECT_EQ(E_INVALIDARG, GetRootIAccessible()->accLocation(
981 &x_left, nullptr, &width, &height, SELF));
982 EXPECT_EQ(E_INVALIDARG, GetRootIAccessible()->accLocation(
983 &x_left, &y_top, nullptr, &height, SELF));
984 EXPECT_EQ(E_INVALIDARG, GetRootIAccessible()->accLocation(
985 &x_left, &y_top, &width, nullptr, SELF));
986 ScopedVariant bad_id(999);
987 EXPECT_EQ(E_INVALIDARG, GetRootIAccessible()->accLocation(
988 &x_left, &y_top, &width, &height, bad_id));
989
990 // Un-set the global offset so that it doesn't affect subsequent tests.
991 TestAXNodeWrapper::SetGlobalCoordinateOffset(gfx::Vector2d(0, 0));
992}
int32_t height
int32_t width

◆ TEST_F() [101/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleName   
)

Definition at line 520 of file ax_platform_node_win_unittest.cc.

520 {
522 root.id = 1;
524 root.SetName("Name");
525 Init(root);
526
527 ComPtr<IAccessible> root_obj(GetRootIAccessible());
529 EXPECT_EQ(S_OK, root_obj->get_accName(SELF, name.Receive()));
530 EXPECT_STREQ(L"Name", name.Get());
531
532 EXPECT_EQ(E_INVALIDARG, root_obj->get_accName(SELF, nullptr));
533 ScopedVariant bad_id(999);
534 ScopedBstr name2;
535 EXPECT_EQ(E_INVALIDARG, root_obj->get_accName(bad_id, name2.Receive()));
536}

◆ TEST_F() [102/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleRole   
)

Definition at line 927 of file ax_platform_node_win_unittest.cc.

927 {
929 root.id = 1;
930 root.child_ids.push_back(2);
931
932 AXNodeData child;
933 child.id = 2;
934
935 Init(root, child);
936 AXNode* child_node = GetRootAsAXNode()->children()[0];
937 ComPtr<IAccessible> child_iaccessible(IAccessibleFromNode(child_node));
938
939 ScopedVariant role;
940
942 child_node->SetData(child);
943 EXPECT_EQ(S_OK, child_iaccessible->get_accRole(SELF, role.Receive()));
944 EXPECT_EQ(ROLE_SYSTEM_ALERT, V_I4(role.ptr()));
945
947 child_node->SetData(child);
948 EXPECT_EQ(S_OK, child_iaccessible->get_accRole(SELF, role.Receive()));
949 EXPECT_EQ(ROLE_SYSTEM_PUSHBUTTON, V_I4(role.ptr()));
950
952 child_node->SetData(child);
953 EXPECT_EQ(S_OK, child_iaccessible->get_accRole(SELF, role.Receive()));
954 EXPECT_EQ(ROLE_SYSTEM_BUTTONMENU, V_I4(role.ptr()));
955
956 EXPECT_EQ(E_INVALIDARG, child_iaccessible->get_accRole(SELF, nullptr));
957 ScopedVariant bad_id(999);
958 EXPECT_EQ(E_INVALIDARG,
959 child_iaccessible->get_accRole(bad_id, role.Receive()));
960}
void SetData(const AXNodeData &src)
Definition: ax_node.cc:373

◆ TEST_F() [103/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleSelectionListBoxOptionMultipleSelected   
)

Definition at line 653 of file ax_platform_node_win_unittest.cc.

654 {
655 AXNodeData list;
656 list.id = 1;
658
659 AXNodeData list_item_1;
660 list_item_1.id = 2;
663 list_item_1.SetName("Name1");
664
665 AXNodeData list_item_2;
666 list_item_2.id = 3;
669 list_item_2.SetName("Name2");
670
671 AXNodeData list_item_3;
672 list_item_3.id = 4;
674 list_item_3.SetName("Name3");
675
676 list.child_ids.push_back(list_item_1.id);
677 list.child_ids.push_back(list_item_2.id);
678 list.child_ids.push_back(list_item_3.id);
679
680 Init(list, list_item_1, list_item_2, list_item_3);
681
682 ComPtr<IAccessible> root_obj(GetRootIAccessible());
683 ASSERT_NE(nullptr, root_obj.Get());
684
685 ScopedVariant selection;
686 EXPECT_EQ(S_OK, root_obj->get_accSelection(selection.Receive()));
687 EXPECT_EQ(VT_UNKNOWN, selection.type());
688 ASSERT_NE(nullptr, selection.ptr());
689
690 // Loop through the selections and make sure we have the right ones.
691 ComPtr<IEnumVARIANT> accessibles;
692 ASSERT_HRESULT_SUCCEEDED(
693 V_UNKNOWN(selection.ptr())->QueryInterface(IID_PPV_ARGS(&accessibles)));
694 ULONG retrieved_count;
695
696 // Check out the first selected item.
697 {
698 ScopedVariant item;
699 HRESULT hr = accessibles->Next(1, item.Receive(), &retrieved_count);
700 EXPECT_EQ(S_OK, hr);
701
702 ComPtr<IAccessible> accessible;
703 ASSERT_HRESULT_SUCCEEDED(
704 V_DISPATCH(item.ptr())->QueryInterface(IID_PPV_ARGS(&accessible)));
706 EXPECT_EQ(S_OK, accessible->get_accName(SELF, name.Receive()));
707 EXPECT_STREQ(L"Name1", name.Get());
708 }
709
710 // And the second selected element.
711 {
712 ScopedVariant item;
713 HRESULT hr = accessibles->Next(1, item.Receive(), &retrieved_count);
714 EXPECT_EQ(S_OK, hr);
715
716 ComPtr<IAccessible> accessible;
717 ASSERT_HRESULT_SUCCEEDED(
718 V_DISPATCH(item.ptr())->QueryInterface(IID_PPV_ARGS(&accessible)));
720 EXPECT_EQ(S_OK, accessible->get_accName(SELF, name.Receive()));
721 EXPECT_STREQ(L"Name2", name.Get());
722 }
723
724 // There shouldn't be any more selected.
725 {
726 ScopedVariant item;
727 HRESULT hr = accessibles->Next(1, item.Receive(), &retrieved_count);
728 EXPECT_EQ(S_FALSE, hr);
729 }
730}
DWORD ULONG
Definition: windows_types.h:40

◆ TEST_F() [104/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleSelectionListBoxOptionNothingSelected   
)

Definition at line 593 of file ax_platform_node_win_unittest.cc.

594 {
595 AXNodeData list;
596 list.id = 1;
598
599 AXNodeData list_item_1;
600 list_item_1.id = 2;
602 list_item_1.SetName("Name1");
603
604 AXNodeData list_item_2;
605 list_item_2.id = 3;
607 list_item_2.SetName("Name2");
608
609 list.child_ids.push_back(list_item_1.id);
610 list.child_ids.push_back(list_item_2.id);
611
612 Init(list, list_item_1, list_item_2);
613
614 ComPtr<IAccessible> root_obj(GetRootIAccessible());
615 ASSERT_NE(nullptr, root_obj.Get());
616
617 ScopedVariant selection;
618 EXPECT_EQ(S_OK, root_obj->get_accSelection(selection.Receive()));
619 EXPECT_EQ(VT_EMPTY, selection.type());
620}

◆ TEST_F() [105/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleSelectionListBoxOptionOneSelected   
)

Definition at line 622 of file ax_platform_node_win_unittest.cc.

622 {
623 AXNodeData list;
624 list.id = 1;
626
627 AXNodeData list_item_1;
628 list_item_1.id = 2;
631 list_item_1.SetName("Name1");
632
633 AXNodeData list_item_2;
634 list_item_2.id = 3;
636 list_item_2.SetName("Name2");
637
638 list.child_ids.push_back(list_item_1.id);
639 list.child_ids.push_back(list_item_2.id);
640
641 Init(list, list_item_1, list_item_2);
642
643 ComPtr<IAccessible> root_obj(GetRootIAccessible());
644 ASSERT_NE(nullptr, root_obj.Get());
645
646 ScopedVariant selection;
647 EXPECT_EQ(S_OK, root_obj->get_accSelection(selection.Receive()));
648 EXPECT_EQ(VT_DISPATCH, selection.type());
649
650 CheckVariantHasName(selection, L"Name1");
651}

◆ TEST_F() [106/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleSelectionTableCellMultipleSelected   
)

Definition at line 862 of file ax_platform_node_win_unittest.cc.

862 {
863 AXTreeUpdate update = Build3X3Table();
864
865 // 11 == table_cell_3
866 // 12 == table_cell_4
867 update.nodes[11].AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, true);
868 update.nodes[12].AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, true);
869
870 Init(update);
871
872 ComPtr<IAccessible> root_obj(GetRootIAccessible());
873 ASSERT_NE(nullptr, root_obj.Get());
874
875 ComPtr<IDispatch> row3;
876 ASSERT_HRESULT_SUCCEEDED(root_obj->get_accChild(ScopedVariant(3), &row3));
877 ComPtr<IAccessible> row3_accessible;
878 ASSERT_HRESULT_SUCCEEDED(row3.As(&row3_accessible));
879
880 ScopedVariant selection;
881 EXPECT_EQ(S_OK, row3_accessible->get_accSelection(selection.Receive()));
882 EXPECT_EQ(VT_UNKNOWN, selection.type());
883 ASSERT_NE(nullptr, selection.ptr());
884
885 // Loop through the selections and make sure we have the right ones.
886 ComPtr<IEnumVARIANT> accessibles;
887 ASSERT_HRESULT_SUCCEEDED(
888 V_UNKNOWN(selection.ptr())->QueryInterface(IID_PPV_ARGS(&accessibles)));
889 ULONG retrieved_count;
890
891 // Check out the first selected cell.
892 {
893 ScopedVariant item;
894 HRESULT hr = accessibles->Next(1, item.Receive(), &retrieved_count);
895 EXPECT_EQ(S_OK, hr);
896
897 ComPtr<IAccessible> accessible;
898 ASSERT_HRESULT_SUCCEEDED(
899 V_DISPATCH(item.ptr())->QueryInterface(IID_PPV_ARGS(&accessible)));
901 EXPECT_EQ(S_OK, accessible->get_accName(SELF, name.Receive()));
902 EXPECT_STREQ(L"3", name.Get());
903 }
904
905 // And the second selected cell.
906 {
907 ScopedVariant item;
908 HRESULT hr = accessibles->Next(1, item.Receive(), &retrieved_count);
909 EXPECT_EQ(S_OK, hr);
910
911 ComPtr<IAccessible> accessible;
912 ASSERT_HRESULT_SUCCEEDED(
913 V_DISPATCH(item.ptr())->QueryInterface(IID_PPV_ARGS(&accessible)));
915 EXPECT_EQ(S_OK, accessible->get_accName(SELF, name.Receive()));
916 EXPECT_STREQ(L"4", name.Get());
917 }
918
919 // There shouldn't be any more selected.
920 {
921 ScopedVariant item;
922 HRESULT hr = accessibles->Next(1, item.Receive(), &retrieved_count);
923 EXPECT_EQ(S_FALSE, hr);
924 }
925}

◆ TEST_F() [107/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleSelectionTableCellOneSelected   
)

Definition at line 828 of file ax_platform_node_win_unittest.cc.

828 {
829 AXTreeUpdate update = Build3X3Table();
830
831 // 7 == table_cell_1
832 update.nodes[7].AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, true);
833
834 Init(update);
835
836 ComPtr<IAccessible> root_obj(GetRootIAccessible());
837 ASSERT_NE(nullptr, root_obj.Get());
838
839 ComPtr<IDispatch> row2;
840 ASSERT_HRESULT_SUCCEEDED(root_obj->get_accChild(ScopedVariant(2), &row2));
841 ComPtr<IAccessible> row2_accessible;
842 ASSERT_HRESULT_SUCCEEDED(row2.As(&row2_accessible));
843
844 ScopedVariant selection;
845 EXPECT_EQ(S_OK, row2_accessible->get_accSelection(selection.Receive()));
846 EXPECT_EQ(VT_DISPATCH, selection.type());
847 ASSERT_NE(nullptr, selection.ptr());
848
849 ComPtr<IAccessible> cell;
850 ASSERT_HRESULT_SUCCEEDED(
851 V_DISPATCH(selection.ptr())->QueryInterface(IID_PPV_ARGS(&cell)));
852
853 ScopedVariant role;
854 EXPECT_HRESULT_SUCCEEDED(cell->get_accRole(SELF, role.Receive()));
855 EXPECT_EQ(ROLE_SYSTEM_CELL, V_I4(role.ptr()));
856
858 EXPECT_EQ(S_OK, cell->get_accName(SELF, name.Receive()));
859 EXPECT_STREQ(L"1", name.Get());
860}

◆ TEST_F() [108/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleSelectionTableNothingSelected   
)

Definition at line 732 of file ax_platform_node_win_unittest.cc.

732 {
733 Init(Build3X3Table());
734
735 ComPtr<IAccessible> root_obj(GetRootIAccessible());
736 ASSERT_NE(nullptr, root_obj.Get());
737
738 ScopedVariant selection;
739 EXPECT_EQ(S_OK, root_obj->get_accSelection(selection.Receive()));
740 EXPECT_EQ(VT_EMPTY, selection.type());
741}

◆ TEST_F() [109/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleSelectionTableRowMultipleSelected   
)

Definition at line 768 of file ax_platform_node_win_unittest.cc.

768 {
769 AXTreeUpdate update = Build3X3Table();
770
771 // 5 == table_row_1
772 // 9 == table_row_2
773 update.nodes[5].AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, true);
774 update.nodes[9].AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, true);
775
776 Init(update);
777
778 ComPtr<IAccessible> root_obj(GetRootIAccessible());
779 ASSERT_NE(nullptr, root_obj.Get());
780
781 ScopedVariant selection;
782 EXPECT_EQ(S_OK, root_obj->get_accSelection(selection.Receive()));
783 EXPECT_EQ(VT_UNKNOWN, selection.type());
784 ASSERT_NE(nullptr, selection.ptr());
785
786 // Loop through the selections and make sure we have the right ones.
787 ComPtr<IEnumVARIANT> accessibles;
788 ASSERT_HRESULT_SUCCEEDED(
789 V_UNKNOWN(selection.ptr())->QueryInterface(IID_PPV_ARGS(&accessibles)));
790 ULONG retrieved_count;
791
792 // Check out the first selected row.
793 {
794 ScopedVariant item;
795 HRESULT hr = accessibles->Next(1, item.Receive(), &retrieved_count);
796 EXPECT_EQ(S_OK, hr);
797
798 ComPtr<IAccessible> accessible;
799 ASSERT_HRESULT_SUCCEEDED(
800 V_DISPATCH(item.ptr())->QueryInterface(IID_PPV_ARGS(&accessible)));
801 ScopedVariant role;
802 EXPECT_HRESULT_SUCCEEDED(accessible->get_accRole(SELF, role.Receive()));
803 EXPECT_EQ(ROLE_SYSTEM_ROW, V_I4(role.ptr()));
804 }
805
806 // And the second selected element.
807 {
808 ScopedVariant item;
809 HRESULT hr = accessibles->Next(1, item.Receive(), &retrieved_count);
810 EXPECT_EQ(S_OK, hr);
811
812 ComPtr<IAccessible> accessible;
813 ASSERT_HRESULT_SUCCEEDED(
814 V_DISPATCH(item.ptr())->QueryInterface(IID_PPV_ARGS(&accessible)));
815 ScopedVariant role;
816 EXPECT_HRESULT_SUCCEEDED(accessible->get_accRole(SELF, role.Receive()));
817 EXPECT_EQ(ROLE_SYSTEM_ROW, V_I4(role.ptr()));
818 }
819
820 // There shouldn't be any more selected.
821 {
822 ScopedVariant item;
823 HRESULT hr = accessibles->Next(1, item.Receive(), &retrieved_count);
824 EXPECT_EQ(S_FALSE, hr);
825 }
826}

◆ TEST_F() [110/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleSelectionTableRowOneSelected   
)

Definition at line 743 of file ax_platform_node_win_unittest.cc.

743 {
744 AXTreeUpdate update = Build3X3Table();
745
746 // 5 == table_row_1
747 update.nodes[5].AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, true);
748
749 Init(update);
750
751 ComPtr<IAccessible> root_obj(GetRootIAccessible());
752 ASSERT_NE(nullptr, root_obj.Get());
753
754 ScopedVariant selection;
755 EXPECT_EQ(S_OK, root_obj->get_accSelection(selection.Receive()));
756 EXPECT_EQ(VT_DISPATCH, selection.type());
757 ASSERT_NE(nullptr, selection.ptr());
758
759 ComPtr<IAccessible> row;
760 ASSERT_HRESULT_SUCCEEDED(
761 V_DISPATCH(selection.ptr())->QueryInterface(IID_PPV_ARGS(&row)));
762
763 ScopedVariant role;
764 EXPECT_HRESULT_SUCCEEDED(row->get_accRole(SELF, role.Receive()));
765 EXPECT_EQ(ROLE_SYSTEM_ROW, V_I4(role.ptr()));
766}

◆ TEST_F() [111/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleShortcut   
)

Definition at line 574 of file ax_platform_node_win_unittest.cc.

574 {
576 root.id = 1;
578 "Shortcut");
579 Init(root);
580
581 ComPtr<IAccessible> root_obj(GetRootIAccessible());
582 ScopedBstr shortcut;
583 EXPECT_EQ(S_OK, root_obj->get_accKeyboardShortcut(SELF, shortcut.Receive()));
584 EXPECT_STREQ(L"Shortcut", shortcut.Get());
585
586 EXPECT_EQ(E_INVALIDARG, root_obj->get_accKeyboardShortcut(SELF, nullptr));
587 ScopedVariant bad_id(999);
588 ScopedBstr k2;
589 EXPECT_EQ(E_INVALIDARG,
590 root_obj->get_accKeyboardShortcut(bad_id, k2.Receive()));
591}

◆ TEST_F() [112/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IExpandCollapsePatternProviderAction   
)

Definition at line 3762 of file ax_platform_node_win_unittest.cc.

3762 {
3764 root.id = 1;
3765
3766 ui::AXNodeData combo_box_grouping_has_popup;
3767 ui::AXNodeData combo_box_grouping_expanded;
3768 ui::AXNodeData combo_box_grouping_collapsed;
3769 ui::AXNodeData combo_box_grouping_disabled;
3770 ui::AXNodeData button_has_popup_menu;
3771 ui::AXNodeData button_has_popup_menu_pressed;
3772 ui::AXNodeData button_has_popup_true;
3773 ui::AXNodeData generic_container_has_popup_menu;
3774
3775 combo_box_grouping_has_popup.id = 2;
3776 combo_box_grouping_expanded.id = 3;
3777 combo_box_grouping_collapsed.id = 4;
3778 combo_box_grouping_disabled.id = 5;
3779 button_has_popup_menu.id = 6;
3780 button_has_popup_menu_pressed.id = 7;
3781 button_has_popup_true.id = 8;
3782 generic_container_has_popup_menu.id = 9;
3783
3784 root.child_ids = {
3785 combo_box_grouping_has_popup.id, combo_box_grouping_expanded.id,
3786 combo_box_grouping_collapsed.id, combo_box_grouping_disabled.id,
3787 button_has_popup_menu.id, button_has_popup_menu_pressed.id,
3788 button_has_popup_true.id, generic_container_has_popup_menu.id};
3789
3790 // combo_box_grouping HasPopup set to true, can collapse, can expand.
3791 // state is ExpandCollapseState_LeafNode.
3792 combo_box_grouping_has_popup.role = ax::mojom::Role::kComboBoxGrouping;
3793 combo_box_grouping_has_popup.SetHasPopup(ax::mojom::HasPopup::kTrue);
3794
3795 // combo_box_grouping Expanded set, can collapse, cannot expand.
3796 // state is ExpandCollapseState_Expanded.
3797 combo_box_grouping_expanded.role = ax::mojom::Role::kComboBoxGrouping;
3798 combo_box_grouping_expanded.AddState(ax::mojom::State::kExpanded);
3799
3800 // combo_box_grouping Collapsed set, can expand, cannot collapse.
3801 // state is ExpandCollapseState_Collapsed.
3802 combo_box_grouping_collapsed.role = ax::mojom::Role::kComboBoxGrouping;
3803 combo_box_grouping_collapsed.AddState(ax::mojom::State::kCollapsed);
3804
3805 // combo_box_grouping is disabled, can neither expand nor collapse.
3806 // state is ExpandCollapseState_LeafNode.
3807 combo_box_grouping_disabled.role = ax::mojom::Role::kComboBoxGrouping;
3808 combo_box_grouping_disabled.SetRestriction(ax::mojom::Restriction::kDisabled);
3809
3810 // button_has_popup_menu HasPopup set to kMenu and is not STATE_PRESSED.
3811 // state is ExpandCollapseState_Collapsed.
3812 button_has_popup_menu.role = ax::mojom::Role::kButton;
3813 button_has_popup_menu.SetHasPopup(ax::mojom::HasPopup::kMenu);
3814
3815 // button_has_popup_menu_pressed HasPopup set to kMenu and is STATE_PRESSED.
3816 // state is ExpandCollapseState_Expanded.
3817 button_has_popup_menu_pressed.role = ax::mojom::Role::kButton;
3818 button_has_popup_menu_pressed.SetHasPopup(ax::mojom::HasPopup::kMenu);
3819 button_has_popup_menu_pressed.SetCheckedState(ax::mojom::CheckedState::kTrue);
3820
3821 // button_has_popup_true HasPopup set to true but is not a menu.
3822 // state is ExpandCollapseState_LeafNode.
3823 button_has_popup_true.role = ax::mojom::Role::kButton;
3824 button_has_popup_true.SetHasPopup(ax::mojom::HasPopup::kTrue);
3825
3826 // generic_container_has_popup_menu HasPopup set to menu but with no expand
3827 // state set.
3828 // state is ExpandCollapseState_LeafNode.
3829 generic_container_has_popup_menu.role = ax::mojom::Role::kGenericContainer;
3830 generic_container_has_popup_menu.SetHasPopup(ax::mojom::HasPopup::kMenu);
3831
3832 Init(root, combo_box_grouping_has_popup, combo_box_grouping_disabled,
3833 combo_box_grouping_expanded, combo_box_grouping_collapsed,
3834 combo_box_grouping_disabled, button_has_popup_menu,
3835 button_has_popup_menu_pressed, button_has_popup_true,
3836 generic_container_has_popup_menu);
3837
3838 // combo_box_grouping HasPopup set to true, can collapse, can expand.
3839 // state is ExpandCollapseState_LeafNode.
3840 ComPtr<IRawElementProviderSimple> raw_element_provider_simple =
3841 GetIRawElementProviderSimpleFromChildIndex(0);
3842 ComPtr<IExpandCollapseProvider> expandcollapse_provider;
3843 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3844 UIA_ExpandCollapsePatternId, &expandcollapse_provider));
3845 ASSERT_NE(nullptr, expandcollapse_provider.Get());
3846 EXPECT_HRESULT_SUCCEEDED(expandcollapse_provider->Collapse());
3847 EXPECT_HRESULT_SUCCEEDED(expandcollapse_provider->Expand());
3848 ExpandCollapseState state;
3849 EXPECT_HRESULT_SUCCEEDED(
3850 expandcollapse_provider->get_ExpandCollapseState(&state));
3851 EXPECT_EQ(ExpandCollapseState_LeafNode, state);
3852
3853 // combo_box_grouping Expanded set, can collapse, cannot expand.
3854 // state is ExpandCollapseState_Expanded.
3855 raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(1);
3856 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3857 UIA_ExpandCollapsePatternId, &expandcollapse_provider));
3858 ASSERT_NE(nullptr, expandcollapse_provider.Get());
3859 EXPECT_HRESULT_SUCCEEDED(expandcollapse_provider->Collapse());
3860 EXPECT_HRESULT_FAILED(expandcollapse_provider->Expand());
3861 EXPECT_HRESULT_SUCCEEDED(
3862 expandcollapse_provider->get_ExpandCollapseState(&state));
3863 EXPECT_EQ(ExpandCollapseState_Expanded, state);
3864
3865 // combo_box_grouping Collapsed set, can expand, cannot collapse.
3866 // state is ExpandCollapseState_Collapsed.
3867 raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(2);
3868 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3869 UIA_ExpandCollapsePatternId, &expandcollapse_provider));
3870 ASSERT_NE(nullptr, expandcollapse_provider.Get());
3871 EXPECT_HRESULT_FAILED(expandcollapse_provider->Collapse());
3872 EXPECT_HRESULT_SUCCEEDED(expandcollapse_provider->Expand());
3873 EXPECT_HRESULT_SUCCEEDED(
3874 expandcollapse_provider->get_ExpandCollapseState(&state));
3875 EXPECT_EQ(ExpandCollapseState_Collapsed, state);
3876
3877 // combo_box_grouping is disabled, can neither expand nor collapse.
3878 // state is ExpandCollapseState_LeafNode.
3879 raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(3);
3880 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3881 UIA_ExpandCollapsePatternId, &expandcollapse_provider));
3882 ASSERT_NE(nullptr, expandcollapse_provider.Get());
3883 EXPECT_HRESULT_FAILED(expandcollapse_provider->Collapse());
3884 EXPECT_HRESULT_FAILED(expandcollapse_provider->Expand());
3885 EXPECT_HRESULT_SUCCEEDED(
3886 expandcollapse_provider->get_ExpandCollapseState(&state));
3887 EXPECT_EQ(ExpandCollapseState_LeafNode, state);
3888
3889 // button_has_popup_menu HasPopup set to kMenu and is not STATE_PRESSED.
3890 // state is ExpandCollapseState_Collapsed.
3891 raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(4);
3892 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3893 UIA_ExpandCollapsePatternId, &expandcollapse_provider));
3894 ASSERT_NE(nullptr, expandcollapse_provider.Get());
3895 EXPECT_HRESULT_SUCCEEDED(
3896 expandcollapse_provider->get_ExpandCollapseState(&state));
3897 EXPECT_EQ(ExpandCollapseState_Collapsed, state);
3898
3899 // button_has_popup_menu_pressed HasPopup set to kMenu and is STATE_PRESSED.
3900 // state is ExpandCollapseState_Expanded.
3901 raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(5);
3902 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3903 UIA_ExpandCollapsePatternId, &expandcollapse_provider));
3904 ASSERT_NE(nullptr, expandcollapse_provider.Get());
3905 EXPECT_HRESULT_SUCCEEDED(
3906 expandcollapse_provider->get_ExpandCollapseState(&state));
3907 EXPECT_EQ(ExpandCollapseState_Expanded, state);
3908
3909 // button_has_popup_true HasPopup set to true but is not a menu.
3910 // state is ExpandCollapseState_LeafNode.
3911 raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(6);
3912 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3913 UIA_ExpandCollapsePatternId, &expandcollapse_provider));
3914 ASSERT_NE(nullptr, expandcollapse_provider.Get());
3915 EXPECT_HRESULT_SUCCEEDED(
3916 expandcollapse_provider->get_ExpandCollapseState(&state));
3917 EXPECT_EQ(ExpandCollapseState_LeafNode, state);
3918
3919 // generic_container_has_popup_menu HasPopup set to menu but with no expand
3920 // state set.
3921 // state is ExpandCollapseState_LeafNode.
3922 raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(7);
3923 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3924 UIA_ExpandCollapsePatternId, &expandcollapse_provider));
3925 ASSERT_NE(nullptr, expandcollapse_provider.Get());
3926 EXPECT_HRESULT_SUCCEEDED(
3927 expandcollapse_provider->get_ExpandCollapseState(&state));
3928 EXPECT_EQ(ExpandCollapseState_LeafNode, state);
3929}

◆ TEST_F() [113/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IGridProviderGetColumnCount   
)

Definition at line 1345 of file ax_platform_node_win_unittest.cc.

1345 {
1346 Init(BuildAriaColumnAndRowCountGrids());
1347
1348 // Empty Grid
1349 ComPtr<IGridProvider> grid1_provider =
1350 QueryInterfaceFromNode<IGridProvider>(GetRootAsAXNode()->children()[0]);
1351
1352 // Grid with a cell that defines aria-rowindex (4) and aria-colindex (5)
1353 ComPtr<IGridProvider> grid2_provider =
1354 QueryInterfaceFromNode<IGridProvider>(GetRootAsAXNode()->children()[1]);
1355
1356 // Grid that specifies aria-rowcount (2) and aria-colcount (3)
1357 ComPtr<IGridProvider> grid3_provider =
1358 QueryInterfaceFromNode<IGridProvider>(GetRootAsAXNode()->children()[2]);
1359
1360 // Grid that specifies aria-rowcount and aria-colcount are both (-1)
1361 ComPtr<IGridProvider> grid4_provider =
1362 QueryInterfaceFromNode<IGridProvider>(GetRootAsAXNode()->children()[3]);
1363
1364 int column_count;
1365
1366 EXPECT_HRESULT_SUCCEEDED(grid1_provider->get_ColumnCount(&column_count));
1367 EXPECT_EQ(column_count, 0);
1368
1369 EXPECT_HRESULT_SUCCEEDED(grid2_provider->get_ColumnCount(&column_count));
1370 EXPECT_EQ(column_count, 5);
1371
1372 EXPECT_HRESULT_SUCCEEDED(grid3_provider->get_ColumnCount(&column_count));
1373 EXPECT_EQ(column_count, 3);
1374
1375 EXPECT_EQ(E_UNEXPECTED, grid4_provider->get_ColumnCount(&column_count));
1376}

◆ TEST_F() [114/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IGridProviderGetItem   
)

Definition at line 1378 of file ax_platform_node_win_unittest.cc.

1378 {
1380 root.id = 1;
1382 root.AddIntAttribute(ax::mojom::IntAttribute::kAriaRowCount, 1);
1384
1385 AXNodeData row1;
1386 row1.id = 2;
1388 root.child_ids.push_back(row1.id);
1389
1390 AXNodeData cell1;
1391 cell1.id = 3;
1393 row1.child_ids.push_back(cell1.id);
1394
1395 Init(root, row1, cell1);
1396
1397 ComPtr<IGridProvider> root_igridprovider(
1398 QueryInterfaceFromNode<IGridProvider>(GetRootAsAXNode()));
1399
1400 ComPtr<IRawElementProviderSimple> cell1_irawelementprovidersimple(
1401 QueryInterfaceFromNode<IRawElementProviderSimple>(
1402 GetRootAsAXNode()->children()[0]->children()[0]));
1403
1404 IRawElementProviderSimple* grid_item = nullptr;
1405 EXPECT_HRESULT_SUCCEEDED(root_igridprovider->GetItem(0, 0, &grid_item));
1406 EXPECT_NE(nullptr, grid_item);
1407 EXPECT_EQ(cell1_irawelementprovidersimple.Get(), grid_item);
1408}

◆ TEST_F() [115/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IGridProviderGetRowCount   
)

Definition at line 1312 of file ax_platform_node_win_unittest.cc.

1312 {
1313 Init(BuildAriaColumnAndRowCountGrids());
1314
1315 // Empty Grid
1316 ComPtr<IGridProvider> grid1_provider =
1317 QueryInterfaceFromNode<IGridProvider>(GetRootAsAXNode()->children()[0]);
1318
1319 // Grid with a cell that defines aria-rowindex (4) and aria-colindex (5)
1320 ComPtr<IGridProvider> grid2_provider =
1321 QueryInterfaceFromNode<IGridProvider>(GetRootAsAXNode()->children()[1]);
1322
1323 // Grid that specifies aria-rowcount (2) and aria-colcount (3)
1324 ComPtr<IGridProvider> grid3_provider =
1325 QueryInterfaceFromNode<IGridProvider>(GetRootAsAXNode()->children()[2]);
1326
1327 // Grid that specifies aria-rowcount and aria-colcount are both (-1)
1328 ComPtr<IGridProvider> grid4_provider =
1329 QueryInterfaceFromNode<IGridProvider>(GetRootAsAXNode()->children()[3]);
1330
1331 int row_count;
1332
1333 EXPECT_HRESULT_SUCCEEDED(grid1_provider->get_RowCount(&row_count));
1334 EXPECT_EQ(row_count, 0);
1335
1336 EXPECT_HRESULT_SUCCEEDED(grid2_provider->get_RowCount(&row_count));
1337 EXPECT_EQ(row_count, 4);
1338
1339 EXPECT_HRESULT_SUCCEEDED(grid3_provider->get_RowCount(&row_count));
1340 EXPECT_EQ(row_count, 2);
1341
1342 EXPECT_EQ(E_UNEXPECTED, grid4_provider->get_RowCount(&row_count));
1343}

◆ TEST_F() [116/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IInvokeProviderInvoke   
)

Definition at line 3931 of file ax_platform_node_win_unittest.cc.

3931 {
3933 root.id = 1;
3934
3935 ui::AXNodeData button;
3936 ui::AXNodeData button_disabled;
3937
3938 button.id = 2;
3939 button_disabled.id = 3;
3940
3941 root.child_ids.push_back(button.id);
3942 root.child_ids.push_back(button_disabled.id);
3943
3944 // generic button can be invoked.
3946
3947 // disabled button, cannot be invoked.
3948 button_disabled.role = ax::mojom::Role::kButton;
3950
3951 Init(root, button, button_disabled);
3952 AXNode* button_node = GetRootAsAXNode()->children()[0];
3953
3954 // generic button can be invoked.
3955 ComPtr<IRawElementProviderSimple> raw_element_provider_simple =
3956 GetIRawElementProviderSimpleFromChildIndex(0);
3957 ComPtr<IInvokeProvider> invoke_provider;
3958 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3959 UIA_InvokePatternId, &invoke_provider));
3960 EXPECT_NE(nullptr, invoke_provider.Get());
3961 EXPECT_HRESULT_SUCCEEDED(invoke_provider->Invoke());
3962 EXPECT_EQ(button_node, TestAXNodeWrapper::GetNodeFromLastDefaultAction());
3963
3964 // disabled button, cannot be invoked.
3965 raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(1);
3966 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3967 UIA_InvokePatternId, &invoke_provider));
3968 EXPECT_NE(nullptr, invoke_provider.Get());
3969 EXPECT_UIA_ELEMENTNOTENABLED(invoke_provider->Invoke());
3970}
#define EXPECT_UIA_ELEMENTNOTENABLED(expr)

◆ TEST_F() [117/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IRawElementProviderSimple2ShowContextMenu   
)

Definition at line 3166 of file ax_platform_node_win_unittest.cc.

3166 {
3167 AXNodeData root_data;
3168 root_data.id = 1;
3169
3170 AXNodeData element1_data;
3171 element1_data.id = 2;
3172 root_data.child_ids.push_back(element1_data.id);
3173
3174 AXNodeData element2_data;
3175 element2_data.id = 3;
3176 root_data.child_ids.push_back(element2_data.id);
3177
3178 Init(root_data, element1_data, element2_data);
3179
3180 AXNode* root_node = GetRootAsAXNode();
3181 AXNode* element1_node = root_node->children()[0];
3182 AXNode* element2_node = root_node->children()[1];
3183
3184 ComPtr<IRawElementProviderSimple2> root_provider =
3185 QueryInterfaceFromNode<IRawElementProviderSimple2>(root_node);
3186 ComPtr<IRawElementProviderSimple2> element1_provider =
3187 QueryInterfaceFromNode<IRawElementProviderSimple2>(element1_node);
3188 ComPtr<IRawElementProviderSimple2> element2_provider =
3189 QueryInterfaceFromNode<IRawElementProviderSimple2>(element2_node);
3190
3191 EXPECT_HRESULT_SUCCEEDED(element1_provider->ShowContextMenu());
3192 EXPECT_EQ(element1_node, TestAXNodeWrapper::GetNodeFromLastShowContextMenu());
3193 EXPECT_HRESULT_SUCCEEDED(element2_provider->ShowContextMenu());
3194 EXPECT_EQ(element2_node, TestAXNodeWrapper::GetNodeFromLastShowContextMenu());
3195 EXPECT_HRESULT_SUCCEEDED(root_provider->ShowContextMenu());
3196 EXPECT_EQ(root_node, TestAXNodeWrapper::GetNodeFromLastShowContextMenu());
3197}

◆ TEST_F() [118/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IScrollProviderSetScrollPercent   
)

Definition at line 4607 of file ax_platform_node_win_unittest.cc.

4607 {
4609 root.id = 1;
4611 root.AddIntAttribute(ax::mojom::IntAttribute::kScrollX, 0);
4612 root.AddIntAttribute(ax::mojom::IntAttribute::kScrollXMin, 0);
4613 root.AddIntAttribute(ax::mojom::IntAttribute::kScrollXMax, 100);
4614
4615 root.AddIntAttribute(ax::mojom::IntAttribute::kScrollY, 60);
4616 root.AddIntAttribute(ax::mojom::IntAttribute::kScrollYMin, 10);
4617 root.AddIntAttribute(ax::mojom::IntAttribute::kScrollYMax, 60);
4618
4619 Init(root);
4620
4621 ComPtr<IScrollProvider> scroll_provider =
4622 QueryInterfaceFromNode<IScrollProvider>(GetRootAsAXNode());
4623 double x_scroll_percent;
4624 double y_scroll_percent;
4625
4626 // Set x scroll percent: 0%, y scroll percent: 0%.
4627 // Expected x scroll percent: 0%, y scroll percent: 0%.
4628 EXPECT_HRESULT_SUCCEEDED(scroll_provider->SetScrollPercent(0, 0));
4629 EXPECT_HRESULT_SUCCEEDED(
4630 scroll_provider->get_HorizontalScrollPercent(&x_scroll_percent));
4631 EXPECT_EQ(x_scroll_percent, 0);
4632 EXPECT_HRESULT_SUCCEEDED(
4633 scroll_provider->get_VerticalScrollPercent(&y_scroll_percent));
4634 EXPECT_EQ(y_scroll_percent, 0);
4635
4636 // Set x scroll percent: 100%, y scroll percent: 100%.
4637 // Expected x scroll percent: 100%, y scroll percent: 100%.
4638 EXPECT_HRESULT_SUCCEEDED(scroll_provider->SetScrollPercent(100, 100));
4639 EXPECT_HRESULT_SUCCEEDED(
4640 scroll_provider->get_HorizontalScrollPercent(&x_scroll_percent));
4641 EXPECT_EQ(x_scroll_percent, 100);
4642 EXPECT_HRESULT_SUCCEEDED(
4643 scroll_provider->get_VerticalScrollPercent(&y_scroll_percent));
4644 EXPECT_EQ(y_scroll_percent, 100);
4645
4646 // Set x scroll percent: 500%, y scroll percent: 600%.
4647 // Expected x scroll percent: 100%, y scroll percent: 100%.
4648 EXPECT_HRESULT_SUCCEEDED(scroll_provider->SetScrollPercent(500, 600));
4649 EXPECT_HRESULT_SUCCEEDED(
4650 scroll_provider->get_HorizontalScrollPercent(&x_scroll_percent));
4651 EXPECT_EQ(x_scroll_percent, 100);
4652 EXPECT_HRESULT_SUCCEEDED(
4653 scroll_provider->get_VerticalScrollPercent(&y_scroll_percent));
4654 EXPECT_EQ(y_scroll_percent, 100);
4655
4656 // Set x scroll percent: -100%, y scroll percent: -200%.
4657 // Expected x scroll percent: 0%, y scroll percent: 0%.
4658 EXPECT_HRESULT_SUCCEEDED(scroll_provider->SetScrollPercent(-100, -200));
4659 EXPECT_HRESULT_SUCCEEDED(
4660 scroll_provider->get_HorizontalScrollPercent(&x_scroll_percent));
4661 EXPECT_EQ(x_scroll_percent, 0);
4662 EXPECT_HRESULT_SUCCEEDED(
4663 scroll_provider->get_VerticalScrollPercent(&y_scroll_percent));
4664 EXPECT_EQ(y_scroll_percent, 0);
4665
4666 // Set x scroll percent: 12%, y scroll percent: 34%.
4667 // Expected x scroll percent: 12%, y scroll percent: 34%.
4668 EXPECT_HRESULT_SUCCEEDED(scroll_provider->SetScrollPercent(12, 34));
4669 EXPECT_HRESULT_SUCCEEDED(
4670 scroll_provider->get_HorizontalScrollPercent(&x_scroll_percent));
4671 EXPECT_EQ(x_scroll_percent, 12);
4672 EXPECT_HRESULT_SUCCEEDED(
4673 scroll_provider->get_VerticalScrollPercent(&y_scroll_percent));
4674 EXPECT_EQ(y_scroll_percent, 34);
4675}

◆ TEST_F() [119/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionItemProviderDisabled   
)

Definition at line 3987 of file ax_platform_node_win_unittest.cc.

3987 {
3989 root.id = 1;
3991 static_cast<int>(ax::mojom::Restriction::kDisabled));
3992 root.AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, true);
3994
3995 Init(root);
3996
3997 ComPtr<IRawElementProviderSimple> raw_element_provider_simple =
3998 GetRootIRawElementProviderSimple();
3999 ComPtr<ISelectionItemProvider> selection_item_provider;
4000 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
4001 UIA_SelectionItemPatternId, &selection_item_provider));
4002 ASSERT_NE(nullptr, selection_item_provider.Get());
4003
4004 BOOL selected;
4005
4006 EXPECT_UIA_ELEMENTNOTENABLED(selection_item_provider->AddToSelection());
4007 EXPECT_UIA_ELEMENTNOTENABLED(selection_item_provider->RemoveFromSelection());
4008 EXPECT_UIA_ELEMENTNOTENABLED(selection_item_provider->Select());
4009 EXPECT_HRESULT_SUCCEEDED(selection_item_provider->get_IsSelected(&selected));
4010 EXPECT_TRUE(selected);
4011}

◆ TEST_F() [120/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionItemProviderGetSelectionContainer   
)

Definition at line 4356 of file ax_platform_node_win_unittest.cc.

4356 {
4358 root.id = 1;
4360
4361 AXNodeData row1;
4362 row1.id = 2;
4364 root.child_ids.push_back(row1.id);
4365
4366 AXNodeData cell1;
4367 cell1.id = 3;
4370 row1.child_ids.push_back(cell1.id);
4371
4372 Init(root, row1, cell1);
4373
4374 ComPtr<IRawElementProviderSimple> container_provider =
4375 GetRootIRawElementProviderSimple();
4376
4377 const auto* row = GetRootAsAXNode()->children()[0];
4378 ComPtr<ISelectionItemProvider> item_provider =
4379 QueryInterfaceFromNode<ISelectionItemProvider>(row->children()[0]);
4380
4381 ComPtr<IRawElementProviderSimple> container;
4382 EXPECT_HRESULT_SUCCEEDED(item_provider->get_SelectionContainer(&container));
4383 EXPECT_NE(nullptr, container);
4384 EXPECT_EQ(container, container_provider);
4385}

◆ TEST_F() [121/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionItemProviderGrid   
)

Definition at line 4289 of file ax_platform_node_win_unittest.cc.

4289 {
4291 root.id = 1;
4293
4294 AXNodeData row1;
4295 row1.id = 2;
4297 root.child_ids.push_back(row1.id);
4298
4299 AXNodeData cell1;
4300 cell1.id = 3;
4303 row1.child_ids.push_back(cell1.id);
4304
4305 Init(root, row1, cell1);
4306
4307 const auto* row = GetRootAsAXNode()->children()[0];
4308 ComPtr<IRawElementProviderSimple> raw_element_provider_simple =
4309 QueryInterfaceFromNode<IRawElementProviderSimple>(row->children()[0]);
4310
4311 ComPtr<ISelectionItemProvider> selection_item_provider;
4312 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
4313 UIA_SelectionItemPatternId, &selection_item_provider));
4314 ASSERT_NE(nullptr, selection_item_provider.Get());
4315
4316 BOOL selected;
4317
4318 // Note: TestAXNodeWrapper::AccessibilityPerformAction will
4319 // flip kSelected for kCell when the kDoDefault action is fired.
4320
4321 // Initial State
4322 EXPECT_HRESULT_SUCCEEDED(selection_item_provider->get_IsSelected(&selected));
4323 EXPECT_FALSE(selected);
4324
4325 // AddToSelection should fire event when not selected
4326 EXPECT_HRESULT_SUCCEEDED(selection_item_provider->AddToSelection());
4327 EXPECT_HRESULT_SUCCEEDED(selection_item_provider->get_IsSelected(&selected));
4328 EXPECT_TRUE(selected);
4329
4330 // AddToSelection should not fire event when selected
4331 EXPECT_HRESULT_SUCCEEDED(selection_item_provider->AddToSelection());
4332 EXPECT_HRESULT_SUCCEEDED(selection_item_provider->get_IsSelected(&selected));
4333 EXPECT_TRUE(selected);
4334
4335 // RemoveFromSelection should fire event when selected
4336 EXPECT_HRESULT_SUCCEEDED(selection_item_provider->RemoveFromSelection());
4337 EXPECT_HRESULT_SUCCEEDED(selection_item_provider->get_IsSelected(&selected));
4338 EXPECT_FALSE(selected);
4339
4340 // RemoveFromSelection should not fire event when not selected
4341 EXPECT_HRESULT_SUCCEEDED(selection_item_provider->RemoveFromSelection());
4342 EXPECT_HRESULT_SUCCEEDED(selection_item_provider->get_IsSelected(&selected));
4343 EXPECT_FALSE(selected);
4344
4345 // Select should fire event when not selected
4346 EXPECT_HRESULT_SUCCEEDED(selection_item_provider->Select());
4347 EXPECT_HRESULT_SUCCEEDED(selection_item_provider->get_IsSelected(&selected));
4348 EXPECT_TRUE(selected);
4349
4350 // Select should not fire event when selected
4351 EXPECT_HRESULT_SUCCEEDED(selection_item_provider->Select());
4352 EXPECT_HRESULT_SUCCEEDED(selection_item_provider->get_IsSelected(&selected));
4353 EXPECT_TRUE(selected);
4354}

◆ TEST_F() [122/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionItemProviderMenuItemRadio   
)

Definition at line 4176 of file ax_platform_node_win_unittest.cc.

4176 {
4178 root.id = 1;
4180
4181 // CheckedState::kNone
4182 AXNodeData option1;
4183 option1.id = 2;
4185 static_cast<int>(ax::mojom::CheckedState::kNone));
4187 root.child_ids.push_back(option1.id);
4188
4189 // CheckedState::kFalse
4190 AXNodeData option2;
4191 option2.id = 3;
4193 static_cast<int>(ax::mojom::CheckedState::kFalse));
4195 root.child_ids.push_back(option2.id);
4196
4197 // CheckedState::kTrue
4198 AXNodeData option3;
4199 option3.id = 4;
4201 static_cast<int>(ax::mojom::CheckedState::kTrue));
4203 root.child_ids.push_back(option3.id);
4204
4205 // CheckedState::kMixed
4206 AXNodeData option4;
4207 option4.id = 5;
4209 static_cast<int>(ax::mojom::CheckedState::kMixed));
4211 root.child_ids.push_back(option4.id);
4212
4213 Init(root, option1, option2, option3, option4);
4214
4215 BOOL selected;
4216
4217 // Option 1, CheckedState::kNone, ISelectionItemProvider is not supported.
4218 ComPtr<ISelectionItemProvider> option1_provider;
4219 EXPECT_HRESULT_SUCCEEDED(
4220 GetIRawElementProviderSimpleFromChildIndex(0)->GetPatternProvider(
4221 UIA_SelectionItemPatternId, &option1_provider));
4222 ASSERT_EQ(nullptr, option1_provider.Get());
4223
4224 // Option 2, CheckedState::kFalse.
4225 ComPtr<ISelectionItemProvider> option2_provider;
4226 EXPECT_HRESULT_SUCCEEDED(
4227 GetIRawElementProviderSimpleFromChildIndex(1)->GetPatternProvider(
4228 UIA_SelectionItemPatternId, &option2_provider));
4229 ASSERT_NE(nullptr, option2_provider.Get());
4230
4231 EXPECT_HRESULT_SUCCEEDED(option2_provider->get_IsSelected(&selected));
4232 EXPECT_FALSE(selected);
4233
4234 EXPECT_HRESULT_SUCCEEDED(option2_provider->Select());
4235 EXPECT_HRESULT_SUCCEEDED(option2_provider->get_IsSelected(&selected));
4236 EXPECT_TRUE(selected);
4237
4238 // Option 3, CheckedState::kTrue.
4239 ComPtr<ISelectionItemProvider> option3_provider;
4240 EXPECT_HRESULT_SUCCEEDED(
4241 GetIRawElementProviderSimpleFromChildIndex(2)->GetPatternProvider(
4242 UIA_SelectionItemPatternId, &option3_provider));
4243 ASSERT_NE(nullptr, option3_provider.Get());
4244
4245 EXPECT_HRESULT_SUCCEEDED(option3_provider->get_IsSelected(&selected));
4246 EXPECT_TRUE(selected);
4247
4248 EXPECT_HRESULT_SUCCEEDED(option3_provider->RemoveFromSelection());
4249 EXPECT_HRESULT_SUCCEEDED(option3_provider->get_IsSelected(&selected));
4250 EXPECT_FALSE(selected);
4251
4252 EXPECT_HRESULT_SUCCEEDED(option3_provider->AddToSelection());
4253 EXPECT_HRESULT_SUCCEEDED(option3_provider->get_IsSelected(&selected));
4254 EXPECT_TRUE(selected);
4255
4256 // Option 4, CheckedState::kMixed, ISelectionItemProvider is not supported.
4257 ComPtr<ISelectionItemProvider> option4_provider;
4258 EXPECT_HRESULT_SUCCEEDED(
4259 GetIRawElementProviderSimpleFromChildIndex(3)->GetPatternProvider(
4260 UIA_SelectionItemPatternId, &option4_provider));
4261 ASSERT_EQ(nullptr, option4_provider.Get());
4262}

◆ TEST_F() [123/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionItemProviderNotSelectable   
)

Definition at line 4013 of file ax_platform_node_win_unittest.cc.

4013 {
4015 root.id = 1;
4017
4018 Init(root);
4019
4020 ComPtr<IRawElementProviderSimple> raw_element_provider_simple =
4021 GetRootIRawElementProviderSimple();
4022 ComPtr<ISelectionItemProvider> selection_item_provider;
4023 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
4024 UIA_SelectionItemPatternId, &selection_item_provider));
4025 ASSERT_EQ(nullptr, selection_item_provider.Get());
4026}

◆ TEST_F() [124/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionItemProviderNotSupported   
)

Definition at line 3972 of file ax_platform_node_win_unittest.cc.

3972 {
3974 root.id = 1;
3976
3977 Init(root);
3978
3979 ComPtr<IRawElementProviderSimple> raw_element_provider_simple =
3980 GetRootIRawElementProviderSimple();
3981 ComPtr<ISelectionItemProvider> selection_item_provider;
3982 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
3983 UIA_SelectionItemPatternId, &selection_item_provider));
3984 ASSERT_EQ(nullptr, selection_item_provider.Get());
3985}

◆ TEST_F() [125/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionItemProviderRadioButton   
)

Definition at line 4088 of file ax_platform_node_win_unittest.cc.

4088 {
4090 root.id = 1;
4092
4093 // CheckedState::kNone
4094 AXNodeData option1;
4095 option1.id = 2;
4097 static_cast<int>(ax::mojom::CheckedState::kNone));
4099 root.child_ids.push_back(option1.id);
4100
4101 // CheckedState::kFalse
4102 AXNodeData option2;
4103 option2.id = 3;
4105 static_cast<int>(ax::mojom::CheckedState::kFalse));
4107 root.child_ids.push_back(option2.id);
4108
4109 // CheckedState::kTrue
4110 AXNodeData option3;
4111 option3.id = 4;
4113 static_cast<int>(ax::mojom::CheckedState::kTrue));
4115 root.child_ids.push_back(option3.id);
4116
4117 // CheckedState::kMixed
4118 AXNodeData option4;
4119 option4.id = 5;
4121 static_cast<int>(ax::mojom::CheckedState::kMixed));
4123 root.child_ids.push_back(option4.id);
4124
4125 Init(root, option1, option2, option3, option4);
4126
4127 BOOL selected;
4128
4129 // Option 1, CheckedState::kNone, ISelectionItemProvider is not supported.
4130 ComPtr<ISelectionItemProvider> option1_provider;
4131 EXPECT_HRESULT_SUCCEEDED(
4132 GetIRawElementProviderSimpleFromChildIndex(0)->GetPatternProvider(
4133 UIA_SelectionItemPatternId, &option1_provider));
4134 ASSERT_EQ(nullptr, option1_provider.Get());
4135
4136 // Option 2, CheckedState::kFalse.
4137 ComPtr<ISelectionItemProvider> option2_provider;
4138 EXPECT_HRESULT_SUCCEEDED(
4139 GetIRawElementProviderSimpleFromChildIndex(1)->GetPatternProvider(
4140 UIA_SelectionItemPatternId, &option2_provider));
4141 ASSERT_NE(nullptr, option2_provider.Get());
4142
4143 EXPECT_HRESULT_SUCCEEDED(option2_provider->get_IsSelected(&selected));
4144 EXPECT_FALSE(selected);
4145
4146 EXPECT_HRESULT_SUCCEEDED(option2_provider->Select());
4147 EXPECT_HRESULT_SUCCEEDED(option2_provider->get_IsSelected(&selected));
4148 EXPECT_TRUE(selected);
4149
4150 // Option 3, CheckedState::kTrue.
4151 ComPtr<ISelectionItemProvider> option3_provider;
4152 EXPECT_HRESULT_SUCCEEDED(
4153 GetIRawElementProviderSimpleFromChildIndex(2)->GetPatternProvider(
4154 UIA_SelectionItemPatternId, &option3_provider));
4155 ASSERT_NE(nullptr, option3_provider.Get());
4156
4157 EXPECT_HRESULT_SUCCEEDED(option3_provider->get_IsSelected(&selected));
4158 EXPECT_TRUE(selected);
4159
4160 EXPECT_HRESULT_SUCCEEDED(option3_provider->RemoveFromSelection());
4161 EXPECT_HRESULT_SUCCEEDED(option3_provider->get_IsSelected(&selected));
4162 EXPECT_FALSE(selected);
4163
4164 EXPECT_HRESULT_SUCCEEDED(option3_provider->AddToSelection());
4165 EXPECT_HRESULT_SUCCEEDED(option3_provider->get_IsSelected(&selected));
4166 EXPECT_TRUE(selected);
4167
4168 // Option 4, CheckedState::kMixed, ISelectionItemProvider is not supported.
4169 ComPtr<ISelectionItemProvider> option4_provider;
4170 EXPECT_HRESULT_SUCCEEDED(
4171 GetIRawElementProviderSimpleFromChildIndex(3)->GetPatternProvider(
4172 UIA_SelectionItemPatternId, &option4_provider));
4173 ASSERT_EQ(nullptr, option4_provider.Get());
4174}

◆ TEST_F() [126/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionItemProviderSelectFollowFocus   
)

Definition at line 4387 of file ax_platform_node_win_unittest.cc.

4387 {
4389 root.id = 1;
4391
4392 AXNodeData tab1;
4393 tab1.id = 2;
4397 root.child_ids.push_back(tab1.id);
4398
4399 Init(root, tab1);
4400
4401 auto* tab1_node = GetRootAsAXNode()->children()[0];
4402 ComPtr<IRawElementProviderSimple> tab1_raw_element_provider_simple =
4403 QueryInterfaceFromNode<IRawElementProviderSimple>(tab1_node);
4404 ASSERT_NE(nullptr, tab1_raw_element_provider_simple.Get());
4405
4406 ComPtr<IRawElementProviderFragment> tab1_raw_element_provider_fragment =
4407 IRawElementProviderFragmentFromNode(tab1_node);
4408 ASSERT_NE(nullptr, tab1_raw_element_provider_fragment.Get());
4409
4410 ComPtr<ISelectionItemProvider> tab1_selection_item_provider;
4411 EXPECT_HRESULT_SUCCEEDED(tab1_raw_element_provider_simple->GetPatternProvider(
4412 UIA_SelectionItemPatternId, &tab1_selection_item_provider));
4413 ASSERT_NE(nullptr, tab1_selection_item_provider.Get());
4414
4415 BOOL is_selected;
4416 // Before setting focus to "tab1", validate that "tab1" has selected=false.
4417 tab1_selection_item_provider->get_IsSelected(&is_selected);
4418 EXPECT_FALSE(is_selected);
4419
4420 // Setting focus on "tab1" will result in selected=true.
4421 tab1_raw_element_provider_fragment->SetFocus();
4422 tab1_selection_item_provider->get_IsSelected(&is_selected);
4423 EXPECT_TRUE(is_selected);
4424
4425 // Verify that we can still trigger action::kDoDefault through Select().
4426 EXPECT_HRESULT_SUCCEEDED(tab1_selection_item_provider->Select());
4427 tab1_selection_item_provider->get_IsSelected(&is_selected);
4428 EXPECT_TRUE(is_selected);
4429 EXPECT_EQ(tab1_node, TestAXNodeWrapper::GetNodeFromLastDefaultAction());
4430 // Verify that after Select(), "tab1" is still selected.
4431 tab1_selection_item_provider->get_IsSelected(&is_selected);
4432 EXPECT_TRUE(is_selected);
4433
4434 // Since last Select() performed |action::kDoDefault|, which set
4435 // |kSelectedFromFocus| to false. Calling Select() again will not perform
4436 // |action::kDoDefault| again.
4437 TestAXNodeWrapper::SetNodeFromLastDefaultAction(nullptr);
4438 EXPECT_HRESULT_SUCCEEDED(tab1_selection_item_provider->Select());
4439 tab1_selection_item_provider->get_IsSelected(&is_selected);
4440 EXPECT_TRUE(is_selected);
4441 // Verify that after Select(),|action::kDoDefault| was not triggered on
4442 // "tab1".
4443 EXPECT_EQ(nullptr, TestAXNodeWrapper::GetNodeFromLastDefaultAction());
4444}

◆ TEST_F() [127/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionItemProviderSimple   
)

Definition at line 4028 of file ax_platform_node_win_unittest.cc.

4028 {
4030 root.id = 1;
4032
4033 AXNodeData option1;
4034 option1.id = 2;
4037 root.child_ids.push_back(option1.id);
4038
4039 Init(root, option1);
4040
4041 ComPtr<IRawElementProviderSimple> raw_element_provider_simple =
4042 GetIRawElementProviderSimpleFromChildIndex(0);
4043 ComPtr<ISelectionItemProvider> option1_provider;
4044 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
4045 UIA_SelectionItemPatternId, &option1_provider));
4046 ASSERT_NE(nullptr, option1_provider.Get());
4047
4048 BOOL selected;
4049
4050 // Note: TestAXNodeWrapper::AccessibilityPerformAction will
4051 // flip kSelected for kListBoxOption when the kDoDefault action is fired.
4052
4053 // Initial State
4054 EXPECT_HRESULT_SUCCEEDED(option1_provider->get_IsSelected(&selected));
4055 EXPECT_FALSE(selected);
4056
4057 // AddToSelection should fire event when not selected
4058 EXPECT_HRESULT_SUCCEEDED(option1_provider->AddToSelection());
4059 EXPECT_HRESULT_SUCCEEDED(option1_provider->get_IsSelected(&selected));
4060 EXPECT_TRUE(selected);
4061
4062 // AddToSelection should not fire event when selected
4063 EXPECT_HRESULT_SUCCEEDED(option1_provider->AddToSelection());
4064 EXPECT_HRESULT_SUCCEEDED(option1_provider->get_IsSelected(&selected));
4065 EXPECT_TRUE(selected);
4066
4067 // RemoveFromSelection should fire event when selected
4068 EXPECT_HRESULT_SUCCEEDED(option1_provider->RemoveFromSelection());
4069 EXPECT_HRESULT_SUCCEEDED(option1_provider->get_IsSelected(&selected));
4070 EXPECT_FALSE(selected);
4071
4072 // RemoveFromSelection should not fire event when not selected
4073 EXPECT_HRESULT_SUCCEEDED(option1_provider->RemoveFromSelection());
4074 EXPECT_HRESULT_SUCCEEDED(option1_provider->get_IsSelected(&selected));
4075 EXPECT_FALSE(selected);
4076
4077 // Select should fire event when not selected
4078 EXPECT_HRESULT_SUCCEEDED(option1_provider->Select());
4079 EXPECT_HRESULT_SUCCEEDED(option1_provider->get_IsSelected(&selected));
4080 EXPECT_TRUE(selected);
4081
4082 // Select should not fire event when selected
4083 EXPECT_HRESULT_SUCCEEDED(option1_provider->Select());
4084 EXPECT_HRESULT_SUCCEEDED(option1_provider->get_IsSelected(&selected));
4085 EXPECT_TRUE(selected);
4086}

◆ TEST_F() [128/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionItemProviderTable   
)

Definition at line 4264 of file ax_platform_node_win_unittest.cc.

4264 {
4266 root.id = 1;
4268
4269 AXNodeData row1;
4270 row1.id = 2;
4272 root.child_ids.push_back(row1.id);
4273
4274 AXNodeData cell1;
4275 cell1.id = 3;
4278 row1.child_ids.push_back(cell1.id);
4279
4280 Init(root, row1, cell1);
4281
4282 ComPtr<ISelectionItemProvider> selection_item_provider;
4283 EXPECT_HRESULT_SUCCEEDED(
4284 GetIRawElementProviderSimpleFromChildIndex(0)->GetPatternProvider(
4285 UIA_SelectionItemPatternId, &selection_item_provider));
4286 ASSERT_EQ(nullptr, selection_item_provider.Get());
4287}

◆ TEST_F() [129/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionProviderCanSelectMultipleDefault   
)

Definition at line 2867 of file ax_platform_node_win_unittest.cc.

2867 {
2868 Init(BuildListBox(/*option_1_is_selected*/ false,
2869 /*option_2_is_selected*/ false,
2870 /*option_3_is_selected*/ false, {}));
2871
2872 ComPtr<ISelectionProvider> selection_provider(
2873 QueryInterfaceFromNode<ISelectionProvider>(GetRootAsAXNode()));
2874
2875 BOOL multiple = TRUE;
2876 EXPECT_HRESULT_SUCCEEDED(
2877 selection_provider->get_CanSelectMultiple(&multiple));
2878 EXPECT_FALSE(multiple);
2879}

◆ TEST_F() [130/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionProviderCanSelectMultipleTrue   
)

Definition at line 2881 of file ax_platform_node_win_unittest.cc.

2881 {
2882 const std::vector<ax::mojom::State> state = {
2884 Init(BuildListBox(/*option_1_is_selected*/ false,
2885 /*option_2_is_selected*/ false,
2886 /*option_3_is_selected*/ false,
2887 /*additional_state*/ state));
2888
2889 ComPtr<ISelectionProvider> selection_provider(
2890 QueryInterfaceFromNode<ISelectionProvider>(GetRootAsAXNode()));
2891
2892 BOOL multiple = FALSE;
2893 EXPECT_HRESULT_SUCCEEDED(
2894 selection_provider->get_CanSelectMultiple(&multiple));
2895 EXPECT_TRUE(multiple);
2896}

◆ TEST_F() [131/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionProviderGetSelectionMultipleItemsSelected   
)

Definition at line 2988 of file ax_platform_node_win_unittest.cc.

2989 {
2990 const std::vector<ax::mojom::State> state = {
2992 Init(BuildListBox(/*option_1_is_selected*/ true,
2993 /*option_2_is_selected*/ true,
2994 /*option_3_is_selected*/ true,
2995 /*additional_state*/ state));
2996
2997 ComPtr<ISelectionProvider> selection_provider(
2998 QueryInterfaceFromNode<ISelectionProvider>(GetRootAsAXNode()));
2999 ComPtr<IRawElementProviderSimple> option1_provider(
3000 QueryInterfaceFromNode<IRawElementProviderSimple>(
3001 GetRootAsAXNode()->children()[0]));
3002 ComPtr<IRawElementProviderSimple> option2_provider(
3003 QueryInterfaceFromNode<IRawElementProviderSimple>(
3004 GetRootAsAXNode()->children()[1]));
3005 ComPtr<IRawElementProviderSimple> option3_provider(
3006 QueryInterfaceFromNode<IRawElementProviderSimple>(
3007 GetRootAsAXNode()->children()[2]));
3008
3009 base::win::ScopedSafearray selected_items;
3010 EXPECT_HRESULT_SUCCEEDED(
3011 selection_provider->GetSelection(selected_items.Receive()));
3012 EXPECT_NE(nullptr, selected_items.Get());
3013
3014 LONG array_lower_bound;
3015 EXPECT_HRESULT_SUCCEEDED(
3016 ::SafeArrayGetLBound(selected_items.Get(), 1, &array_lower_bound));
3017 EXPECT_EQ(0, array_lower_bound);
3018
3019 LONG array_upper_bound;
3020 EXPECT_HRESULT_SUCCEEDED(
3021 ::SafeArrayGetUBound(selected_items.Get(), 1, &array_upper_bound));
3022 EXPECT_EQ(2, array_upper_bound);
3023
3024 IRawElementProviderSimple** array_data;
3025 EXPECT_HRESULT_SUCCEEDED(::SafeArrayAccessData(
3026 selected_items.Get(), reinterpret_cast<void**>(&array_data)));
3027 EXPECT_EQ(option1_provider.Get(), array_data[0]);
3028 EXPECT_EQ(option2_provider.Get(), array_data[1]);
3029 EXPECT_EQ(option3_provider.Get(), array_data[2]);
3030
3031 EXPECT_HRESULT_SUCCEEDED(::SafeArrayUnaccessData(selected_items.Get()));
3032}

◆ TEST_F() [132/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionProviderGetSelectionNoneSelected   
)

Definition at line 2928 of file ax_platform_node_win_unittest.cc.

2928 {
2929 Init(BuildListBox(/*option_1_is_selected*/ false,
2930 /*option_2_is_selected*/ false,
2931 /*option_3_is_selected*/ false,
2932 /*additional_state*/ {ax::mojom::State::kFocusable}));
2933
2934 ComPtr<ISelectionProvider> selection_provider(
2935 QueryInterfaceFromNode<ISelectionProvider>(GetRootAsAXNode()));
2936
2937 base::win::ScopedSafearray selected_items;
2938 EXPECT_HRESULT_SUCCEEDED(
2939 selection_provider->GetSelection(selected_items.Receive()));
2940 EXPECT_NE(nullptr, selected_items.Get());
2941
2942 LONG array_lower_bound;
2943 EXPECT_HRESULT_SUCCEEDED(
2944 ::SafeArrayGetLBound(selected_items.Get(), 1, &array_lower_bound));
2945 EXPECT_EQ(0, array_lower_bound);
2946
2947 LONG array_upper_bound;
2948 EXPECT_HRESULT_SUCCEEDED(
2949 ::SafeArrayGetUBound(selected_items.Get(), 1, &array_upper_bound));
2950 EXPECT_EQ(-1, array_upper_bound);
2951}

◆ TEST_F() [133/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionProviderGetSelectionSingleItemSelected   
)

Definition at line 2953 of file ax_platform_node_win_unittest.cc.

2954 {
2955 Init(BuildListBox(/*option_1_is_selected*/ false,
2956 /*option_2_is_selected*/ true,
2957 /*option_3_is_selected*/ false,
2958 /*additional_state*/ {ax::mojom::State::kFocusable}));
2959
2960 ComPtr<ISelectionProvider> selection_provider(
2961 QueryInterfaceFromNode<ISelectionProvider>(GetRootAsAXNode()));
2962 ComPtr<IRawElementProviderSimple> option2_provider(
2963 QueryInterfaceFromNode<IRawElementProviderSimple>(
2964 GetRootAsAXNode()->children()[1]));
2965
2966 base::win::ScopedSafearray selected_items;
2967 EXPECT_HRESULT_SUCCEEDED(
2968 selection_provider->GetSelection(selected_items.Receive()));
2969 EXPECT_NE(nullptr, selected_items.Get());
2970
2971 LONG array_lower_bound;
2972 EXPECT_HRESULT_SUCCEEDED(
2973 ::SafeArrayGetLBound(selected_items.Get(), 1, &array_lower_bound));
2974 EXPECT_EQ(0, array_lower_bound);
2975
2976 LONG array_upper_bound;
2977 EXPECT_HRESULT_SUCCEEDED(
2978 ::SafeArrayGetUBound(selected_items.Get(), 1, &array_upper_bound));
2979 EXPECT_EQ(0, array_upper_bound);
2980
2981 IRawElementProviderSimple** array_data;
2982 EXPECT_HRESULT_SUCCEEDED(::SafeArrayAccessData(
2983 selected_items.Get(), reinterpret_cast<void**>(&array_data)));
2984 EXPECT_EQ(option2_provider.Get(), array_data[0]);
2985 EXPECT_HRESULT_SUCCEEDED(::SafeArrayUnaccessData(selected_items.Get()));
2986}

◆ TEST_F() [134/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionProviderIsSelectionRequiredDefault   
)

Definition at line 2898 of file ax_platform_node_win_unittest.cc.

2898 {
2899 Init(BuildListBox(/*option_1_is_selected*/ false,
2900 /*option_2_is_selected*/ false,
2901 /*option_3_is_selected*/ false,
2902 /*additional_state*/ {}));
2903
2904 ComPtr<ISelectionProvider> selection_provider(
2905 QueryInterfaceFromNode<ISelectionProvider>(GetRootAsAXNode()));
2906
2907 BOOL selection_required = TRUE;
2908 EXPECT_HRESULT_SUCCEEDED(
2909 selection_provider->get_IsSelectionRequired(&selection_required));
2910 EXPECT_FALSE(selection_required);
2911}

◆ TEST_F() [135/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionProviderIsSelectionRequiredTrue   
)

Definition at line 2913 of file ax_platform_node_win_unittest.cc.

2913 {
2914 Init(BuildListBox(/*option_1_is_selected*/ false,
2915 /*option_2_is_selected*/ false,
2916 /*option_3_is_selected*/ false,
2917 /*additional_state*/ {ax::mojom::State::kRequired}));
2918
2919 ComPtr<ISelectionProvider> selection_provider(
2920 QueryInterfaceFromNode<ISelectionProvider>(GetRootAsAXNode()));
2921
2922 BOOL selection_required = FALSE;
2923 EXPECT_HRESULT_SUCCEEDED(
2924 selection_provider->get_IsSelectionRequired(&selection_required));
2925 EXPECT_TRUE(selection_required);
2926}

◆ TEST_F() [136/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ITableItemProviderGetColumnHeaderItems   
)

Definition at line 1638 of file ax_platform_node_win_unittest.cc.

1638 {
1640 root.id = 1;
1642
1643 AXNodeData row1;
1644 row1.id = 2;
1646 root.child_ids.push_back(row1.id);
1647
1648 AXNodeData column_header_1;
1649 column_header_1.id = 3;
1650 column_header_1.role = ax::mojom::Role::kColumnHeader;
1651 column_header_1.SetName(u"column_header_1");
1652 row1.child_ids.push_back(column_header_1.id);
1653
1654 AXNodeData column_header_2;
1655 column_header_2.id = 4;
1656 column_header_2.role = ax::mojom::Role::kColumnHeader;
1657 column_header_2.SetName(u"column_header_2");
1658 row1.child_ids.push_back(column_header_2.id);
1659
1660 AXNodeData row2;
1661 row2.id = 5;
1663 root.child_ids.push_back(row2.id);
1664
1665 AXNodeData cell;
1666 cell.id = 6;
1668 row2.child_ids.push_back(cell.id);
1669
1670 Init(root, row1, column_header_1, column_header_2, row2, cell);
1671
1672 TestAXNodeWrapper* root_wrapper =
1673 TestAXNodeWrapper::GetOrCreate(GetTree(), GetRootAsAXNode());
1674 root_wrapper->BuildAllWrappers(GetTree(), GetRootAsAXNode());
1675
1676 ComPtr<ITableItemProvider> cell_itableitemprovider(
1677 QueryInterfaceFromNode<ITableItemProvider>(
1678 GetRootAsAXNode()->children()[1]->children()[0]));
1679
1681 EXPECT_HRESULT_SUCCEEDED(
1682 cell_itableitemprovider->GetColumnHeaderItems(safearray.Receive()));
1683 EXPECT_NE(nullptr, safearray.Get());
1684
1685 std::vector<std::wstring> expected_names = {L"column_header_1"};
1686 EXPECT_UIA_ELEMENT_ARRAY_BSTR_EQ(safearray.Get(), UIA_NamePropertyId,
1687 expected_names);
1688
1689 // Remove column_header_1's native event target and verify it's no longer
1690 // returned.
1691 TestAXNodeWrapper* column_header_wrapper = TestAXNodeWrapper::GetOrCreate(
1692 GetTree(), GetRootAsAXNode()->children()[0]->children()[0]);
1693 column_header_wrapper->ResetNativeEventTarget();
1694
1695 safearray.Release();
1696 EXPECT_HRESULT_SUCCEEDED(
1697 cell_itableitemprovider->GetColumnHeaderItems(safearray.Receive()));
1698 EXPECT_EQ(nullptr, safearray.Get());
1699}
#define EXPECT_UIA_ELEMENT_ARRAY_BSTR_EQ(array, element_test_property_id, expected_property_values)
void BuildAllWrappers(AXTree *tree, AXNode *node)

◆ TEST_F() [137/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ITableItemProviderGetRowHeaderItems   
)

Definition at line 1701 of file ax_platform_node_win_unittest.cc.

1701 {
1703 root.id = 1;
1705
1706 AXNodeData row1;
1707 row1.id = 2;
1709 root.child_ids.push_back(row1.id);
1710
1711 AXNodeData row_header_1;
1712 row_header_1.id = 3;
1713 row_header_1.role = ax::mojom::Role::kRowHeader;
1714 row_header_1.SetName(u"row_header_1");
1715 row1.child_ids.push_back(row_header_1.id);
1716
1717 AXNodeData cell;
1718 cell.id = 4;
1720 row1.child_ids.push_back(cell.id);
1721
1722 AXNodeData row2;
1723 row2.id = 5;
1725 root.child_ids.push_back(row2.id);
1726
1727 AXNodeData row_header_2;
1728 row_header_2.id = 6;
1729 row_header_2.role = ax::mojom::Role::kRowHeader;
1730 row_header_2.SetName(u"row_header_2");
1731 row2.child_ids.push_back(row_header_2.id);
1732
1733 Init(root, row1, row_header_1, cell, row2, row_header_2);
1734
1735 TestAXNodeWrapper* root_wrapper =
1736 TestAXNodeWrapper::GetOrCreate(GetTree(), GetRootAsAXNode());
1737 root_wrapper->BuildAllWrappers(GetTree(), GetRootAsAXNode());
1738
1739 ComPtr<ITableItemProvider> cell_itableitemprovider(
1740 QueryInterfaceFromNode<ITableItemProvider>(
1741 GetRootAsAXNode()->children()[0]->children()[1]));
1742
1744 EXPECT_HRESULT_SUCCEEDED(
1745 cell_itableitemprovider->GetRowHeaderItems(safearray.Receive()));
1746 EXPECT_NE(nullptr, safearray.Get());
1747 std::vector<std::wstring> expected_names = {L"row_header_1"};
1748 EXPECT_UIA_ELEMENT_ARRAY_BSTR_EQ(safearray.Get(), UIA_NamePropertyId,
1749 expected_names);
1750
1751 // Remove row_header_1's native event target and verify it's no longer
1752 // returned.
1753 TestAXNodeWrapper* row_header_wrapper = TestAXNodeWrapper::GetOrCreate(
1754 GetTree(), GetRootAsAXNode()->children()[0]->children()[0]);
1755 row_header_wrapper->ResetNativeEventTarget();
1756
1757 safearray.Release();
1758 EXPECT_HRESULT_SUCCEEDED(
1759 cell_itableitemprovider->GetRowHeaderItems(safearray.Receive()));
1760 EXPECT_EQ(nullptr, safearray.Get());
1761}

◆ TEST_F() [138/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ITableProviderGetColumnHeaders   
)

Definition at line 1410 of file ax_platform_node_win_unittest.cc.

1410 {
1412 root.id = 1;
1414
1415 AXNodeData row1;
1416 row1.id = 2;
1418 root.child_ids.push_back(row1.id);
1419
1420 AXNodeData column_header;
1421 column_header.id = 3;
1422 column_header.role = ax::mojom::Role::kColumnHeader;
1423 column_header.SetName(u"column_header");
1424 row1.child_ids.push_back(column_header.id);
1425
1426 AXNodeData row_header;
1427 row_header.id = 4;
1428 row_header.role = ax::mojom::Role::kRowHeader;
1429 row_header.SetName(u"row_header");
1430 row1.child_ids.push_back(row_header.id);
1431
1432 Init(root, row1, column_header, row_header);
1433
1434 ComPtr<ITableProvider> root_itableprovider(
1435 QueryInterfaceFromNode<ITableProvider>(GetRootAsAXNode()));
1436
1438 EXPECT_HRESULT_SUCCEEDED(
1439 root_itableprovider->GetColumnHeaders(safearray.Receive()));
1440 EXPECT_NE(nullptr, safearray.Get());
1441
1442 std::vector<std::wstring> expected_names = {L"column_header"};
1443 EXPECT_UIA_ELEMENT_ARRAY_BSTR_EQ(safearray.Get(), UIA_NamePropertyId,
1444 expected_names);
1445
1446 // Remove column_header's native event target and verify it's no longer
1447 // returned.
1448 TestAXNodeWrapper* column_header_wrapper = TestAXNodeWrapper::GetOrCreate(
1449 GetTree(), GetRootAsAXNode()->children()[0]->children()[0]);
1450 column_header_wrapper->ResetNativeEventTarget();
1451
1452 safearray.Release();
1453 EXPECT_HRESULT_SUCCEEDED(
1454 root_itableprovider->GetColumnHeaders(safearray.Receive()));
1455 EXPECT_EQ(nullptr, safearray.Get());
1456}

◆ TEST_F() [139/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ITableProviderGetColumnHeadersMultipleHeaders   
)

Definition at line 1458 of file ax_platform_node_win_unittest.cc.

1458 {
1459 // Build a table like this:
1460 // header_r1c1 | header_r1c2 | header_r1c3
1461 // cell_r2c1 | cell_r2c2 | cell_r2c3
1462 // cell_r3c1 | header_r3c2 |
1463
1464 // <table>
1465 // <tr aria-label="row1">
1466 // <th>header_r1c1</th>
1467 // <th>header_r1c2</th>
1468 // <th>header_r1c3</th>
1469 // </tr>
1470 // <tr aria-label="row2">
1471 // <td>cell_r2c1</td>
1472 // <td>cell_r2c2</td>
1473 // <td>cell_r2c3</td>
1474 // </tr>
1475 // <tr aria-label="row3">
1476 // <td>cell_r3c1</td>
1477 // <th>header_r3c2</th>
1478 // </tr>
1479 // </table>
1480
1482 root.id = 1;
1484
1485 AXNodeData row1;
1486 row1.id = 2;
1488 root.child_ids.push_back(row1.id);
1489
1490 AXNodeData row2;
1491 row2.id = 3;
1493 root.child_ids.push_back(row2.id);
1494
1495 AXNodeData row3;
1496 row3.id = 4;
1498 root.child_ids.push_back(row3.id);
1499
1500 // <tr aria-label="row1">
1501 // <th>header_r1c1</th> <th>header_r1c2</th> <th>header_r1c3</th>
1502 // </tr>
1503 AXNodeData header_r1c1;
1504 header_r1c1.id = 5;
1506 header_r1c1.SetName(u"header_r1c1");
1507 row1.child_ids.push_back(header_r1c1.id);
1508
1509 AXNodeData header_r1c2;
1510 header_r1c2.id = 6;
1512 header_r1c2.SetName(u"header_r1c2");
1513 row1.child_ids.push_back(header_r1c2.id);
1514
1515 AXNodeData header_r1c3;
1516 header_r1c3.id = 7;
1518 header_r1c3.SetName(u"header_r1c3");
1519 row1.child_ids.push_back(header_r1c3.id);
1520
1521 // <tr aria-label="row2">
1522 // <td>cell_r2c1</td> <td>cell_r2c2</td> <td>cell_r2c3</td>
1523 // </tr>
1524 AXNodeData cell_r2c1;
1525 cell_r2c1.id = 8;
1526 cell_r2c1.role = ax::mojom::Role::kCell;
1527 cell_r2c1.SetName(u"cell_r2c1");
1528 row2.child_ids.push_back(cell_r2c1.id);
1529
1530 AXNodeData cell_r2c2;
1531 cell_r2c2.id = 9;
1532 cell_r2c2.role = ax::mojom::Role::kCell;
1533 cell_r2c2.SetName(u"cell_r2c2");
1534 row2.child_ids.push_back(cell_r2c2.id);
1535
1536 AXNodeData cell_r2c3;
1537 cell_r2c3.id = 10;
1538 cell_r2c3.role = ax::mojom::Role::kCell;
1539 cell_r2c3.SetName(u"cell_r2c3");
1540 row2.child_ids.push_back(cell_r2c3.id);
1541
1542 // <tr aria-label="row3">
1543 // <td>cell_r3c1</td> <th>header_r3c2</th>
1544 // </tr>
1545 AXNodeData cell_r3c1;
1546 cell_r3c1.id = 11;
1547 cell_r3c1.role = ax::mojom::Role::kCell;
1548 cell_r3c1.SetName(u"cell_r3c1");
1549 row3.child_ids.push_back(cell_r3c1.id);
1550
1551 AXNodeData header_r3c2;
1552 header_r3c2.id = 12;
1554 header_r3c2.SetName(u"header_r3c2");
1555 row3.child_ids.push_back(header_r3c2.id);
1556
1557 Init(root, row1, row2, row3, header_r1c1, header_r1c2, header_r1c3, cell_r2c1,
1558 cell_r2c2, cell_r2c3, cell_r3c1, header_r3c2);
1559
1560 ComPtr<ITableProvider> root_itableprovider(
1561 QueryInterfaceFromNode<ITableProvider>(GetRootAsAXNode()));
1562
1564 EXPECT_HRESULT_SUCCEEDED(
1565 root_itableprovider->GetColumnHeaders(safearray.Receive()));
1566 EXPECT_NE(nullptr, safearray.Get());
1567
1568 // Validate that we retrieve all column headers of the table and in the order
1569 // below.
1570 std::vector<std::wstring> expected_names = {L"header_r1c1", L"header_r1c2",
1571 L"header_r3c2", L"header_r1c3"};
1572 EXPECT_UIA_ELEMENT_ARRAY_BSTR_EQ(safearray.Get(), UIA_NamePropertyId,
1573 expected_names);
1574}

◆ TEST_F() [140/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ITableProviderGetRowHeaders   
)

Definition at line 1576 of file ax_platform_node_win_unittest.cc.

1576 {
1578 root.id = 1;
1580
1581 AXNodeData row1;
1582 row1.id = 2;
1584 root.child_ids.push_back(row1.id);
1585
1586 AXNodeData column_header;
1587 column_header.id = 3;
1588 column_header.role = ax::mojom::Role::kColumnHeader;
1589 column_header.SetName(u"column_header");
1590 row1.child_ids.push_back(column_header.id);
1591
1592 AXNodeData row_header;
1593 row_header.id = 4;
1594 row_header.role = ax::mojom::Role::kRowHeader;
1595 row_header.SetName(u"row_header");
1596 row1.child_ids.push_back(row_header.id);
1597
1598 Init(root, row1, column_header, row_header);
1599
1600 ComPtr<ITableProvider> root_itableprovider(
1601 QueryInterfaceFromNode<ITableProvider>(GetRootAsAXNode()));
1602
1604 EXPECT_HRESULT_SUCCEEDED(
1605 root_itableprovider->GetRowHeaders(safearray.Receive()));
1606 EXPECT_NE(nullptr, safearray.Get());
1607 std::vector<std::wstring> expected_names = {L"row_header"};
1608 EXPECT_UIA_ELEMENT_ARRAY_BSTR_EQ(safearray.Get(), UIA_NamePropertyId,
1609 expected_names);
1610
1611 // Remove row_header's native event target and verify it's no longer returned.
1612 TestAXNodeWrapper* row_header_wrapper = TestAXNodeWrapper::GetOrCreate(
1613 GetTree(), GetRootAsAXNode()->children()[0]->children()[1]);
1614 row_header_wrapper->ResetNativeEventTarget();
1615
1616 safearray.Release();
1617 EXPECT_HRESULT_SUCCEEDED(
1618 root_itableprovider->GetRowHeaders(safearray.Receive()));
1619 EXPECT_EQ(nullptr, safearray.Get());
1620}

◆ TEST_F() [141/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ITableProviderGetRowOrColumnMajor   
)

Definition at line 1622 of file ax_platform_node_win_unittest.cc.

1622 {
1624 root.id = 1;
1626
1627 Init(root);
1628
1629 ComPtr<ITableProvider> root_itableprovider(
1630 QueryInterfaceFromNode<ITableProvider>(GetRootAsAXNode()));
1631
1632 RowOrColumnMajor row_or_column_major;
1633 EXPECT_HRESULT_SUCCEEDED(
1634 root_itableprovider->get_RowOrColumnMajor(&row_or_column_major));
1635 EXPECT_EQ(row_or_column_major, RowOrColumnMajor_RowMajor);
1636}

◆ TEST_F() [142/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IValueProvider_GetValue   
)

Definition at line 4446 of file ax_platform_node_win_unittest.cc.

4446 {
4448 root.id = 1;
4450
4451 AXNodeData child1;
4452 child1.id = 2;
4455 root.child_ids.push_back(child1.id);
4456
4457 AXNodeData child2;
4458 child2.id = 3;
4462 root.child_ids.push_back(child2.id);
4463
4464 AXNodeData child3;
4465 child3.id = 4;
4469 static_cast<int>(ax::mojom::Restriction::kReadOnly));
4470 root.child_ids.push_back(child3.id);
4471
4472 Init(root, child1, child2, child3);
4473
4474 ScopedBstr bstr_value;
4475
4476 EXPECT_HRESULT_SUCCEEDED(
4477 QueryInterfaceFromNode<IValueProvider>(GetRootAsAXNode()->children()[0])
4478 ->get_Value(bstr_value.Receive()));
4479 EXPECT_STREQ(L"3", bstr_value.Get());
4480 bstr_value.Reset();
4481
4482 EXPECT_HRESULT_SUCCEEDED(
4483 QueryInterfaceFromNode<IValueProvider>(GetRootAsAXNode()->children()[1])
4484 ->get_Value(bstr_value.Receive()));
4485 EXPECT_STREQ(L"test", bstr_value.Get());
4486 bstr_value.Reset();
4487
4488 EXPECT_HRESULT_SUCCEEDED(
4489 QueryInterfaceFromNode<IValueProvider>(GetRootAsAXNode()->children()[2])
4490 ->get_Value(bstr_value.Receive()));
4491 EXPECT_STREQ(L"test", bstr_value.Get());
4492 bstr_value.Reset();
4493}

◆ TEST_F() [143/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IValueProvider_IsReadOnly   
)

Definition at line 4552 of file ax_platform_node_win_unittest.cc.

4552 {
4554 root.id = 1;
4556
4557 AXNodeData child1;
4558 child1.id = 2;
4561 root.child_ids.push_back(child1.id);
4562
4563 AXNodeData child2;
4564 child2.id = 3;
4567 static_cast<int>(ax::mojom::Restriction::kReadOnly));
4568 root.child_ids.push_back(child2.id);
4569
4570 AXNodeData child3;
4571 child3.id = 4;
4574 static_cast<int>(ax::mojom::Restriction::kDisabled));
4575 root.child_ids.push_back(child3.id);
4576
4577 AXNodeData child4;
4578 child4.id = 5;
4580 root.child_ids.push_back(child4.id);
4581
4582 Init(root, child1, child2, child3, child4);
4583
4584 BOOL is_readonly = false;
4585
4586 EXPECT_HRESULT_SUCCEEDED(
4587 QueryInterfaceFromNode<IValueProvider>(GetRootAsAXNode()->children()[0])
4588 ->get_IsReadOnly(&is_readonly));
4589 EXPECT_FALSE(is_readonly);
4590
4591 EXPECT_HRESULT_SUCCEEDED(
4592 QueryInterfaceFromNode<IValueProvider>(GetRootAsAXNode()->children()[1])
4593 ->get_IsReadOnly(&is_readonly));
4595
4596 EXPECT_HRESULT_SUCCEEDED(
4597 QueryInterfaceFromNode<IValueProvider>(GetRootAsAXNode()->children()[2])
4598 ->get_IsReadOnly(&is_readonly));
4600
4601 EXPECT_HRESULT_SUCCEEDED(
4602 QueryInterfaceFromNode<IValueProvider>(GetRootAsAXNode()->children()[3])
4603 ->get_IsReadOnly(&is_readonly));
4605}
static bool is_readonly(const InterfaceBlock &block)

◆ TEST_F() [144/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IValueProvider_SetValue   
)

Definition at line 4495 of file ax_platform_node_win_unittest.cc.

4495 {
4497 root.id = 1;
4499
4500 AXNodeData child1;
4501 child1.id = 2;
4504 root.child_ids.push_back(child1.id);
4505
4506 AXNodeData child2;
4507 child2.id = 3;
4510 root.child_ids.push_back(child2.id);
4511
4512 AXNodeData child3;
4513 child3.id = 4;
4517 static_cast<int>(ax::mojom::Restriction::kReadOnly));
4518 root.child_ids.push_back(child3.id);
4519
4520 Init(root, child1, child2, child3);
4521
4522 ComPtr<IValueProvider> root_provider =
4523 QueryInterfaceFromNode<IValueProvider>(GetRootAsAXNode());
4524 ComPtr<IValueProvider> provider1 =
4525 QueryInterfaceFromNode<IValueProvider>(GetRootAsAXNode()->children()[0]);
4526 ComPtr<IValueProvider> provider2 =
4527 QueryInterfaceFromNode<IValueProvider>(GetRootAsAXNode()->children()[1]);
4528 ComPtr<IValueProvider> provider3 =
4529 QueryInterfaceFromNode<IValueProvider>(GetRootAsAXNode()->children()[2]);
4530
4531 ScopedBstr bstr_value;
4532
4533 // Note: TestAXNodeWrapper::AccessibilityPerformAction will
4534 // modify the value when the kSetValue action is fired.
4535
4536 EXPECT_UIA_ELEMENTNOTENABLED(provider1->SetValue(L"2"));
4537 EXPECT_HRESULT_SUCCEEDED(provider1->get_Value(bstr_value.Receive()));
4538 EXPECT_STREQ(L"3", bstr_value.Get());
4539 bstr_value.Reset();
4540
4541 EXPECT_HRESULT_SUCCEEDED(provider2->SetValue(L"changed"));
4542 EXPECT_HRESULT_SUCCEEDED(provider2->get_Value(bstr_value.Receive()));
4543 EXPECT_STREQ(L"changed", bstr_value.Get());
4544 bstr_value.Reset();
4545
4546 EXPECT_UIA_ELEMENTNOTENABLED(provider3->SetValue(L"changed"));
4547 EXPECT_HRESULT_SUCCEEDED(provider3->get_Value(bstr_value.Receive()));
4548 EXPECT_STREQ(L"test", bstr_value.Get());
4549 bstr_value.Reset();
4550}

◆ TEST_F() [145/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
MojoEventToUIAPropertyTest   
)

Definition at line 4677 of file ax_platform_node_win_unittest.cc.

4677 {
4679 root.id = 1;
4682 static_cast<int>(ax::mojom::CheckedState::kMixed));
4683
4684 Init(root);
4685
4686 ComPtr<AXPlatformNodeWin> platform_node =
4687 QueryInterfaceFromNode<AXPlatformNodeWin>(GetRootAsAXNode());
4688 EXPECT_EQ(
4689 platform_node->MojoEventToUIAProperty(ax::mojom::Event::kValueChanged),
4690 UIA_ToggleToggleStatePropertyId);
4691}

◆ TEST_F() [146/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAErrorHandling   
)

Definition at line 3199 of file ax_platform_node_win_unittest.cc.

3199 {
3201 root.id = 1;
3202 Init(root);
3203
3204 ComPtr<IRawElementProviderSimple> simple_provider =
3205 GetRootIRawElementProviderSimple();
3206 ComPtr<IRawElementProviderSimple2> simple2_provider =
3207 QueryInterfaceFromNode<IRawElementProviderSimple2>(GetRootAsAXNode());
3208 ComPtr<IRawElementProviderFragment> fragment_provider =
3209 GetRootIRawElementProviderFragment();
3210 ComPtr<IGridItemProvider> grid_item_provider =
3211 QueryInterfaceFromNode<IGridItemProvider>(GetRootAsAXNode());
3212 ComPtr<IGridProvider> grid_provider =
3213 QueryInterfaceFromNode<IGridProvider>(GetRootAsAXNode());
3214 ComPtr<IScrollItemProvider> scroll_item_provider =
3215 QueryInterfaceFromNode<IScrollItemProvider>(GetRootAsAXNode());
3216 ComPtr<IScrollProvider> scroll_provider =
3217 QueryInterfaceFromNode<IScrollProvider>(GetRootAsAXNode());
3218 ComPtr<ISelectionItemProvider> selection_item_provider =
3219 QueryInterfaceFromNode<ISelectionItemProvider>(GetRootAsAXNode());
3220 ComPtr<ISelectionProvider> selection_provider =
3221 QueryInterfaceFromNode<ISelectionProvider>(GetRootAsAXNode());
3222 ComPtr<ITableItemProvider> table_item_provider =
3223 QueryInterfaceFromNode<ITableItemProvider>(GetRootAsAXNode());
3224 ComPtr<ITableProvider> table_provider =
3225 QueryInterfaceFromNode<ITableProvider>(GetRootAsAXNode());
3226 ComPtr<IExpandCollapseProvider> expand_collapse_provider =
3227 QueryInterfaceFromNode<IExpandCollapseProvider>(GetRootAsAXNode());
3228 ComPtr<IToggleProvider> toggle_provider =
3229 QueryInterfaceFromNode<IToggleProvider>(GetRootAsAXNode());
3230 ComPtr<IValueProvider> value_provider =
3231 QueryInterfaceFromNode<IValueProvider>(GetRootAsAXNode());
3232 ComPtr<IRangeValueProvider> range_value_provider =
3233 QueryInterfaceFromNode<IRangeValueProvider>(GetRootAsAXNode());
3234 ComPtr<IWindowProvider> window_provider =
3235 QueryInterfaceFromNode<IWindowProvider>(GetRootAsAXNode());
3236
3237 // Create an empty tree.
3238 SetTree(std::make_unique<AXTree>());
3239
3240 // IGridItemProvider
3241 int int_result = 0;
3242 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3243 grid_item_provider->get_Column(&int_result));
3244 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3245 grid_item_provider->get_ColumnSpan(&int_result));
3246 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3247 grid_item_provider->get_Row(&int_result));
3248 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3249 grid_item_provider->get_RowSpan(&int_result));
3250
3251 // IExpandCollapseProvider
3252 ExpandCollapseState expand_collapse_state;
3253 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3254 expand_collapse_provider->Collapse());
3255 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3256 expand_collapse_provider->Expand());
3257 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3258 expand_collapse_provider->get_ExpandCollapseState(
3259 &expand_collapse_state));
3260
3261 // IGridProvider
3262 ComPtr<IRawElementProviderSimple> temp_simple_provider;
3263 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3264 grid_provider->GetItem(0, 0, &temp_simple_provider));
3265 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3266 grid_provider->get_RowCount(&int_result));
3267 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3268 grid_provider->get_ColumnCount(&int_result));
3269
3270 // IScrollItemProvider
3271 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3272 scroll_item_provider->ScrollIntoView());
3273
3274 // IScrollProvider
3275 BOOL bool_result = TRUE;
3276 double double_result = 3.14;
3277 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3278 scroll_provider->SetScrollPercent(0, 0));
3279 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3280 scroll_provider->get_HorizontallyScrollable(&bool_result));
3281 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3282 scroll_provider->get_HorizontalScrollPercent(&double_result));
3283 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3284 scroll_provider->get_HorizontalViewSize(&double_result));
3285 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3286 scroll_provider->get_VerticallyScrollable(&bool_result));
3287 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3288 scroll_provider->get_VerticalScrollPercent(&double_result));
3289 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3290 scroll_provider->get_VerticalViewSize(&double_result));
3291
3292 // ISelectionItemProvider
3293 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3294 selection_item_provider->AddToSelection());
3295 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3296 selection_item_provider->RemoveFromSelection());
3297 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3298 selection_item_provider->Select());
3299 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3300 selection_item_provider->get_IsSelected(&bool_result));
3301 EXPECT_EQ(
3302 static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3303 selection_item_provider->get_SelectionContainer(&temp_simple_provider));
3304
3305 // ISelectionProvider
3306 base::win::ScopedSafearray array_result;
3307 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3308 selection_provider->GetSelection(array_result.Receive()));
3309 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3310 selection_provider->get_CanSelectMultiple(&bool_result));
3311 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3312 selection_provider->get_IsSelectionRequired(&bool_result));
3313
3314 // ITableItemProvider
3315 RowOrColumnMajor row_or_column_major_result;
3316 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3317 table_item_provider->GetColumnHeaderItems(array_result.Receive()));
3318 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3319 table_item_provider->GetRowHeaderItems(array_result.Receive()));
3320
3321 // ITableProvider
3322 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3323 table_provider->GetColumnHeaders(array_result.Receive()));
3324 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3325 table_provider->GetRowHeaders(array_result.Receive()));
3326 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3327 table_provider->get_RowOrColumnMajor(&row_or_column_major_result));
3328
3329 // IRawElementProviderSimple
3330 ScopedVariant variant;
3331 ComPtr<IUnknown> unknown;
3332 ComPtr<IRawElementProviderSimple> host_provider;
3333 ProviderOptions options;
3334 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3335 simple_provider->GetPatternProvider(UIA_WindowPatternId, &unknown));
3336 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3337 simple_provider->GetPropertyValue(UIA_FrameworkIdPropertyId,
3338 variant.Receive()));
3339 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3340 simple_provider->get_ProviderOptions(&options));
3341 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3342 simple_provider->get_HostRawElementProvider(&host_provider));
3343
3344 // IRawElementProviderSimple2
3345 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3346 simple2_provider->ShowContextMenu());
3347
3348 // IRawElementProviderFragment
3349 ComPtr<IRawElementProviderFragment> navigated_to_fragment;
3351 UiaRect bounding_rectangle;
3352 ComPtr<IRawElementProviderFragmentRoot> fragment_root;
3353 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3354 fragment_provider->Navigate(NavigateDirection_Parent,
3355 &navigated_to_fragment));
3356 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3357 fragment_provider->GetRuntimeId(safearray.Receive()));
3358 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3359 fragment_provider->get_BoundingRectangle(&bounding_rectangle));
3360 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3361 fragment_provider->GetEmbeddedFragmentRoots(safearray.Receive()));
3362 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3363 fragment_provider->get_FragmentRoot(&fragment_root));
3364 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3365 fragment_provider->SetFocus());
3366
3367 // IValueProvider
3368 ScopedBstr bstr_value;
3369 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3370 value_provider->SetValue(L"3.14"));
3371 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3372 value_provider->get_Value(bstr_value.Receive()));
3373
3374 // IRangeValueProvider
3375 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3376 range_value_provider->SetValue(double_result));
3377 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3378 range_value_provider->get_LargeChange(&double_result));
3379 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3380 range_value_provider->get_Maximum(&double_result));
3381 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3382 range_value_provider->get_Minimum(&double_result));
3383 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3384 range_value_provider->get_SmallChange(&double_result));
3385 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3386 range_value_provider->get_Value(&double_result));
3387
3388 // IToggleProvider
3389 ToggleState toggle_state;
3390 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3391 toggle_provider->Toggle());
3392 EXPECT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3393 toggle_provider->get_ToggleState(&toggle_state));
3394
3395 // IWindowProvider
3396 ASSERT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3397 window_provider->SetVisualState(
3398 WindowVisualState::WindowVisualState_Normal));
3399 ASSERT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3400 window_provider->Close());
3401 ASSERT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3402 window_provider->WaitForInputIdle(0, nullptr));
3403 ASSERT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3404 window_provider->get_CanMaximize(nullptr));
3405 ASSERT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3406 window_provider->get_CanMinimize(nullptr));
3407 ASSERT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3408 window_provider->get_IsModal(nullptr));
3409 ASSERT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3410 window_provider->get_WindowVisualState(nullptr));
3411 ASSERT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3412 window_provider->get_WindowInteractionState(nullptr));
3413 ASSERT_EQ(static_cast<HRESULT>(UIA_E_ELEMENTNOTAVAILABLE),
3414 window_provider->get_IsTopmost(nullptr));
3415}
const char * options

◆ TEST_F() [147/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetBoundingRectangle   
)

Definition at line 2588 of file ax_platform_node_win_unittest.cc.

2588 {
2589 AXNodeData root_data;
2590 root_data.id = 1;
2591 root_data.relative_bounds.bounds = gfx::RectF(10, 20, 30, 50);
2592 Init(root_data);
2593
2594 ComPtr<IRawElementProviderFragment> root_node =
2595 GetRootIRawElementProviderFragment();
2596
2597 UiaRect bounding_rectangle;
2598 EXPECT_HRESULT_SUCCEEDED(
2599 root_node->get_BoundingRectangle(&bounding_rectangle));
2600 EXPECT_EQ(10, bounding_rectangle.left);
2601 EXPECT_EQ(20, bounding_rectangle.top);
2602 EXPECT_EQ(30, bounding_rectangle.width);
2603 EXPECT_EQ(50, bounding_rectangle.height);
2604}

◆ TEST_F() [148/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetControllerForPropertyId   
)

Definition at line 1951 of file ax_platform_node_win_unittest.cc.

1951 {
1953 root.id = 1;
1955 root.child_ids = {2, 3, 4};
1956
1957 AXNodeData tab;
1958 tab.id = 2;
1959 tab.role = ax::mojom::Role::kTab;
1960 tab.SetName("tab");
1961 std::vector<AXNode::AXID> controller_ids = {3, 4};
1962 tab.AddIntListAttribute(ax::mojom::IntListAttribute::kControlsIds,
1963 controller_ids);
1964
1965 AXNodeData panel1;
1966 panel1.id = 3;
1967 panel1.role = ax::mojom::Role::kTabPanel;
1968 panel1.SetName("panel1");
1969
1970 AXNodeData panel2;
1971 panel2.id = 4;
1972 panel2.role = ax::mojom::Role::kTabPanel;
1973 panel2.SetName("panel2");
1974
1975 Init(root, tab, panel1, panel2);
1976 TestAXNodeWrapper* root_wrapper =
1977 TestAXNodeWrapper::GetOrCreate(GetTree(), GetRootAsAXNode());
1978 root_wrapper->BuildAllWrappers(GetTree(), GetRootAsAXNode());
1979
1980 ComPtr<IRawElementProviderSimple> tab_node =
1981 QueryInterfaceFromNode<IRawElementProviderSimple>(
1982 GetRootAsAXNode()->children()[0]);
1983
1984 std::vector<std::wstring> expected_names_1 = {L"panel1", L"panel2"};
1986 tab_node, UIA_ControllerForPropertyId, UIA_NamePropertyId,
1987 expected_names_1);
1988
1989 // Remove panel1's native event target and verify it's no longer returned.
1990 TestAXNodeWrapper* panel1_wrapper = TestAXNodeWrapper::GetOrCreate(
1991 GetTree(), GetRootAsAXNode()->children()[1]);
1992 panel1_wrapper->ResetNativeEventTarget();
1993 std::vector<std::wstring> expected_names_2 = {L"panel2"};
1995 tab_node, UIA_ControllerForPropertyId, UIA_NamePropertyId,
1996 expected_names_2);
1997}
#define EXPECT_UIA_PROPERTY_ELEMENT_ARRAY_BSTR_EQ(node, array_property_id, element_test_property_id, expected_property_values)

◆ TEST_F() [149/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetDescribedByPropertyId   
)

Definition at line 1999 of file ax_platform_node_win_unittest.cc.

1999 {
2001 std::vector<AXNode::AXID> describedby_ids = {2, 3, 4};
2003 describedby_ids);
2004 root.id = 1;
2006 root.SetName("root");
2007
2008 AXNodeData child1;
2009 child1.id = 2;
2010 child1.role = ax::mojom::Role::kStaticText;
2011 child1.SetName("child1");
2012
2013 root.child_ids.push_back(child1.id);
2014
2015 AXNodeData child2;
2016 child2.id = 3;
2017 child2.role = ax::mojom::Role::kStaticText;
2018 child2.SetName("child2");
2019
2020 root.child_ids.push_back(child2.id);
2021
2022 Init(root, child1, child2);
2023
2024 ComPtr<IRawElementProviderSimple> root_node =
2025 GetRootIRawElementProviderSimple();
2026
2027 std::vector<std::wstring> expected_names = {L"child1", L"child2"};
2029 root_node, UIA_DescribedByPropertyId, UIA_NamePropertyId, expected_names);
2030}

◆ TEST_F() [150/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetEmbeddedFragmentRoots   
)

Definition at line 2646 of file ax_platform_node_win_unittest.cc.

2646 {
2647 AXNodeData root_data;
2648 root_data.id = 1;
2649 Init(root_data);
2650
2651 ComPtr<IRawElementProviderFragment> root_provider =
2652 GetRootIRawElementProviderFragment();
2653
2654 base::win::ScopedSafearray embedded_fragment_roots;
2655 EXPECT_HRESULT_SUCCEEDED(root_provider->GetEmbeddedFragmentRoots(
2656 embedded_fragment_roots.Receive()));
2657 EXPECT_EQ(nullptr, embedded_fragment_roots.Get());
2658}

◆ TEST_F() [151/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetFlowsToPropertyId   
)

Definition at line 2100 of file ax_platform_node_win_unittest.cc.

2100 {
2102 std::vector<AXNode::AXID> flowto_ids = {2, 3, 4};
2103 root.AddIntListAttribute(ax::mojom::IntListAttribute::kFlowtoIds, flowto_ids);
2104 root.id = 1;
2106 root.SetName("root");
2107
2108 AXNodeData child1;
2109 child1.id = 2;
2110 child1.role = ax::mojom::Role::kStaticText;
2111 child1.SetName("child1");
2112
2113 root.child_ids.push_back(child1.id);
2114
2115 AXNodeData child2;
2116 child2.id = 3;
2117 child2.role = ax::mojom::Role::kStaticText;
2118 child2.SetName("child2");
2119
2120 root.child_ids.push_back(child2.id);
2121
2122 Init(root, child1, child2);
2123
2124 ComPtr<IRawElementProviderSimple> root_node =
2125 GetRootIRawElementProviderSimple();
2126 std::vector<std::wstring> expected_names = {L"child1", L"child2"};
2127 EXPECT_UIA_PROPERTY_ELEMENT_ARRAY_BSTR_EQ(root_node, UIA_FlowsToPropertyId,
2128 UIA_NamePropertyId, expected_names);
2129}

◆ TEST_F() [152/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetFragmentRoot   
)

Definition at line 2606 of file ax_platform_node_win_unittest.cc.

2606 {
2607 // This test needs to be run on a child node since AXPlatformRootNodeWin
2608 // overrides the method.
2609 AXNodeData root_data;
2610 root_data.id = 1;
2611
2612 AXNodeData element1_data;
2613 element1_data.id = 2;
2614 root_data.child_ids.push_back(element1_data.id);
2615
2616 Init(root_data, element1_data);
2617 InitFragmentRoot();
2618
2619 AXNode* root_node = GetRootAsAXNode();
2620 AXNode* element1_node = root_node->children()[0];
2621
2622 ComPtr<IRawElementProviderFragment> element1_provider =
2623 QueryInterfaceFromNode<IRawElementProviderFragment>(element1_node);
2624 ComPtr<IRawElementProviderFragmentRoot> expected_fragment_root =
2625 GetFragmentRoot();
2626
2627 ComPtr<IRawElementProviderFragmentRoot> actual_fragment_root;
2628 EXPECT_HRESULT_SUCCEEDED(
2629 element1_provider->get_FragmentRoot(&actual_fragment_root));
2630 EXPECT_EQ(expected_fragment_root.Get(), actual_fragment_root.Get());
2631
2632 // Test the case where the fragment root has gone away.
2633 ax_fragment_root_.reset();
2634 actual_fragment_root.Reset();
2636 element1_provider->get_FragmentRoot(&actual_fragment_root));
2637
2638 // Test the case where the widget has gone away.
2639 TestAXNodeWrapper* element1_wrapper =
2640 TestAXNodeWrapper::GetOrCreate(GetTree(), element1_node);
2641 element1_wrapper->ResetNativeEventTarget();
2643 element1_provider->get_FragmentRoot(&actual_fragment_root));
2644}
#define EXPECT_UIA_ELEMENTNOTAVAILABLE(expr)

◆ TEST_F() [153/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetHostRawElementProvider   
)

Definition at line 2574 of file ax_platform_node_win_unittest.cc.

2574 {
2575 AXNodeData root_data;
2576 root_data.id = 1;
2577 Init(root_data);
2578
2579 ComPtr<IRawElementProviderSimple> root_node =
2580 GetRootIRawElementProviderSimple();
2581
2582 ComPtr<IRawElementProviderSimple> host_provider;
2583 EXPECT_HRESULT_SUCCEEDED(
2584 root_node->get_HostRawElementProvider(&host_provider));
2585 EXPECT_EQ(nullptr, host_provider.Get());
2586}

◆ TEST_F() [154/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetPropertySimple   
)

Definition at line 1763 of file ax_platform_node_win_unittest.cc.

1763 {
1766 root.SetName("fake name");
1767 root.AddStringAttribute(ax::mojom::StringAttribute::kAccessKey, "Ctrl+Q");
1768 root.AddStringAttribute(ax::mojom::StringAttribute::kLanguage, "en-us");
1769 root.AddStringAttribute(ax::mojom::StringAttribute::kKeyShortcuts, "Alt+F4");
1771 "fake description");
1772 root.AddIntAttribute(ax::mojom::IntAttribute::kSetSize, 2);
1773 root.AddIntAttribute(ax::mojom::IntAttribute::kInvalidState, 1);
1774 root.id = 1;
1775
1776 AXNodeData child1;
1777 child1.id = 2;
1780 child1.SetName("child1");
1781 root.child_ids.push_back(child1.id);
1782
1783 Init(root, child1);
1784
1785 ComPtr<IRawElementProviderSimple> root_node =
1786 GetRootIRawElementProviderSimple();
1787 ScopedVariant uia_id;
1788 EXPECT_UIA_BSTR_EQ(root_node, UIA_AccessKeyPropertyId, L"Ctrl+Q");
1789 EXPECT_UIA_BSTR_EQ(root_node, UIA_AcceleratorKeyPropertyId, L"Alt+F4");
1790 ASSERT_HRESULT_SUCCEEDED(root_node->GetPropertyValue(
1791 UIA_AutomationIdPropertyId, uia_id.Receive()));
1792 EXPECT_UIA_BSTR_EQ(root_node, UIA_AutomationIdPropertyId,
1793 uia_id.ptr()->bstrVal);
1794 EXPECT_UIA_BSTR_EQ(root_node, UIA_FullDescriptionPropertyId,
1795 L"fake description");
1796 EXPECT_UIA_BSTR_EQ(root_node, UIA_AriaRolePropertyId, L"list");
1797 EXPECT_UIA_BSTR_EQ(root_node, UIA_AriaPropertiesPropertyId,
1798 L"readonly=true;expanded=false;multiline=false;"
1799 L"multiselectable=false;required=false;setsize=2");
1800 constexpr int en_us_lcid = 1033;
1801 EXPECT_UIA_INT_EQ(root_node, UIA_CulturePropertyId, en_us_lcid);
1802 EXPECT_UIA_BSTR_EQ(root_node, UIA_NamePropertyId, L"fake name");
1803 EXPECT_UIA_INT_EQ(root_node, UIA_ControlTypePropertyId,
1804 int{UIA_ListControlTypeId});
1805 EXPECT_UIA_INT_EQ(root_node, UIA_OrientationPropertyId,
1806 int{OrientationType_None});
1807 EXPECT_UIA_INT_EQ(root_node, UIA_SizeOfSetPropertyId, 2);
1808 EXPECT_UIA_INT_EQ(root_node, UIA_ToggleToggleStatePropertyId,
1809 int{ToggleState_Off});
1810 EXPECT_UIA_BOOL_EQ(root_node, UIA_IsPasswordPropertyId, false);
1811 EXPECT_UIA_BOOL_EQ(root_node, UIA_IsEnabledPropertyId, true);
1812 EXPECT_UIA_BOOL_EQ(root_node, UIA_HasKeyboardFocusPropertyId, false);
1813 EXPECT_UIA_BOOL_EQ(root_node, UIA_IsRequiredForFormPropertyId, false);
1814 EXPECT_UIA_BOOL_EQ(root_node, UIA_IsDataValidForFormPropertyId, true);
1815 EXPECT_UIA_BOOL_EQ(root_node, UIA_IsKeyboardFocusablePropertyId, false);
1816 EXPECT_UIA_BOOL_EQ(root_node, UIA_IsOffscreenPropertyId, false);
1817 ComPtr<IRawElementProviderSimple> child_node1 =
1818 QueryInterfaceFromNode<IRawElementProviderSimple>(
1819 GetRootAsAXNode()->children()[0]);
1820 EXPECT_UIA_INT_EQ(child_node1, UIA_PositionInSetPropertyId, 1);
1821}

◆ TEST_F() [155/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetPropertyValueClickablePoint   
)

Definition at line 1823 of file ax_platform_node_win_unittest.cc.

1823 {
1825 root.id = 1;
1827 root.relative_bounds.bounds = gfx::RectF(20, 30, 100, 200);
1828 Init(root);
1829
1830 ComPtr<IRawElementProviderSimple> raw_element_provider_simple =
1831 GetRootIRawElementProviderSimple();
1832
1833 // The clickable point of a rectangle {20, 30, 100, 200} is the rectangle's
1834 // center, with coordinates {x: 70, y: 130}.
1835 std::vector<double> expected_values = {70, 130};
1836 EXPECT_UIA_DOUBLE_ARRAY_EQ(raw_element_provider_simple,
1837 UIA_ClickablePointPropertyId, expected_values);
1838}
#define EXPECT_UIA_DOUBLE_ARRAY_EQ(node, array_property_id, expected_property_values)

◆ TEST_F() [156/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetPropertyValueFlowsFromMultiple   
)

Definition at line 2174 of file ax_platform_node_win_unittest.cc.

2174 {
2176 root.id = 1;
2178 root.SetName("root");
2179 root.AddIntListAttribute(ax::mojom::IntListAttribute::kFlowtoIds, {2, 3});
2180
2181 AXNodeData child1;
2182 child1.id = 2;
2184 child1.SetName("child1");
2185 child1.AddIntListAttribute(ax::mojom::IntListAttribute::kFlowtoIds, {3});
2186 root.child_ids.push_back(child1.id);
2187
2188 AXNodeData child2;
2189 child2.id = 3;
2191 child2.SetName("child2");
2192 root.child_ids.push_back(child2.id);
2193
2194 Init(root, child1, child2);
2195 ASSERT_NE(nullptr,
2196 TestAXNodeWrapper::GetOrCreate(GetTree(), GetRootAsAXNode()));
2197 ASSERT_NE(nullptr, TestAXNodeWrapper::GetOrCreate(
2198 GetTree(), GetRootAsAXNode()->children()[0]));
2199
2200 ComPtr<IRawElementProviderSimple> child_node2 =
2201 QueryInterfaceFromNode<IRawElementProviderSimple>(
2202 GetRootAsAXNode()->children()[1]);
2203 std::vector<std::wstring> expected_names_1 = {L"root", L"child1"};
2205 child_node2, UIA_FlowsFromPropertyId, UIA_NamePropertyId,
2206 expected_names_1);
2207
2208 // Remove child1's native event target and verify it's no longer returned.
2209 TestAXNodeWrapper* child1_wrapper = TestAXNodeWrapper::GetOrCreate(
2210 GetTree(), GetRootAsAXNode()->children()[0]);
2211 child1_wrapper->ResetNativeEventTarget();
2212 std::vector<std::wstring> expected_names_2 = {L"root"};
2214 child_node2, UIA_FlowsFromPropertyId, UIA_NamePropertyId,
2215 expected_names_2);
2216}
#define EXPECT_UIA_PROPERTY_UNORDERED_ELEMENT_ARRAY_BSTR_EQ( node, array_property_id, element_test_property_id, expected_property_values)

◆ TEST_F() [157/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetPropertyValueFlowsFromNone   
)

Definition at line 2131 of file ax_platform_node_win_unittest.cc.

2131 {
2133 root.id = 1;
2135 root.SetName("root");
2136
2137 Init(root);
2138
2139 ComPtr<IRawElementProviderSimple> root_node =
2140 GetRootIRawElementProviderSimple();
2141
2142 ScopedVariant property_value;
2143 EXPECT_HRESULT_SUCCEEDED(root_node->GetPropertyValue(
2144 UIA_FlowsFromPropertyId, property_value.Receive()));
2145 EXPECT_EQ(VT_ARRAY | VT_UNKNOWN, property_value.type());
2146 EXPECT_EQ(nullptr, V_ARRAY(property_value.ptr()));
2147}

◆ TEST_F() [158/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetPropertyValueFlowsFromSingle   
)

Definition at line 2149 of file ax_platform_node_win_unittest.cc.

2149 {
2151 root.id = 1;
2153 root.SetName("root");
2154 root.AddIntListAttribute(ax::mojom::IntListAttribute::kFlowtoIds, {2});
2155
2156 AXNodeData child1;
2157 child1.id = 2;
2159 child1.SetName("child1");
2160 root.child_ids.push_back(child1.id);
2161
2162 Init(root, child1);
2163 ASSERT_NE(nullptr,
2164 TestAXNodeWrapper::GetOrCreate(GetTree(), GetRootAsAXNode()));
2165
2166 ComPtr<IRawElementProviderSimple> child_node1 =
2167 QueryInterfaceFromNode<IRawElementProviderSimple>(
2168 GetRootAsAXNode()->children()[0]);
2169 std::vector<std::wstring> expected_names = {L"root"};
2171 child_node1, UIA_FlowsFromPropertyId, UIA_NamePropertyId, expected_names);
2172}

◆ TEST_F() [159/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetPropertyValueFrameworkId   
)

Definition at line 2218 of file ax_platform_node_win_unittest.cc.

2218 {
2219 AXNodeData root_ax_node_data;
2220 root_ax_node_data.id = 1;
2221 root_ax_node_data.role = ax::mojom::Role::kRootWebArea;
2222 Init(root_ax_node_data);
2223
2224 ComPtr<IRawElementProviderSimple> root_raw_element_provider_simple =
2225 GetRootIRawElementProviderSimple();
2226 EXPECT_UIA_BSTR_EQ(root_raw_element_provider_simple,
2227 UIA_FrameworkIdPropertyId, L"Chrome");
2228}

◆ TEST_F() [160/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetPropertyValueIsControlElementIgnoredInvisible   
)

Definition at line 1864 of file ax_platform_node_win_unittest.cc.

1865 {
1867 root.id = 1;
1869 root.child_ids = {2, 3, 4, 5, 6, 7, 8};
1870
1871 AXNodeData normal_button;
1872 normal_button.id = 2;
1873 normal_button.role = ax::mojom::Role::kButton;
1874
1875 AXNodeData ignored_button;
1876 ignored_button.id = 3;
1877 ignored_button.role = ax::mojom::Role::kButton;
1878 ignored_button.AddState(ax::mojom::State::kIgnored);
1879
1880 AXNodeData invisible_button;
1881 invisible_button.id = 4;
1882 invisible_button.role = ax::mojom::Role::kButton;
1883 invisible_button.AddState(ax::mojom::State::kInvisible);
1884
1885 AXNodeData invisible_focusable_button;
1886 invisible_focusable_button.id = 5;
1887 invisible_focusable_button.role = ax::mojom::Role::kButton;
1888 invisible_focusable_button.AddState(ax::mojom::State::kInvisible);
1889 invisible_focusable_button.AddState(ax::mojom::State::kFocusable);
1890
1891 AXNodeData focusable_generic_container;
1892 focusable_generic_container.id = 6;
1893 focusable_generic_container.role = ax::mojom::Role::kGenericContainer;
1894 focusable_generic_container.AddState(ax::mojom::State::kFocusable);
1895
1896 AXNodeData ignored_focusable_generic_container;
1897 ignored_focusable_generic_container.id = 7;
1898 ignored_focusable_generic_container.role = ax::mojom::Role::kGenericContainer;
1899 ignored_focusable_generic_container.AddState(ax::mojom::State::kIgnored);
1900 focusable_generic_container.AddState(ax::mojom::State::kFocusable);
1901
1902 AXNodeData invisible_focusable_generic_container;
1903 invisible_focusable_generic_container.id = 8;
1904 invisible_focusable_generic_container.role =
1906 invisible_focusable_generic_container.AddState(ax::mojom::State::kInvisible);
1907 invisible_focusable_generic_container.AddState(ax::mojom::State::kFocusable);
1908
1909 Init(root, normal_button, ignored_button, invisible_button,
1910 invisible_focusable_button, focusable_generic_container,
1911 ignored_focusable_generic_container,
1912 invisible_focusable_generic_container);
1913
1914 // Turn on web content mode for the AXTree.
1915 TestAXNodeWrapper::SetGlobalIsWebContent(true);
1916
1917 // Normal button (id=2), no invisible or ignored state set. Should be a
1918 // control element.
1919 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromChildIndex(0),
1920 UIA_IsControlElementPropertyId, true);
1921
1922 // Button with ignored state (id=3). Should not be a control element.
1923 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromChildIndex(1),
1924 UIA_IsControlElementPropertyId, false);
1925
1926 // Button with invisible state (id=4). Should not be a control element.
1927 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromChildIndex(2),
1928 UIA_IsControlElementPropertyId, false);
1929
1930 // Button with invisible state, but focusable (id=5). Should not be a control
1931 // element.
1932 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromChildIndex(3),
1933 UIA_IsControlElementPropertyId, false);
1934
1935 // Generic container, focusable (id=6). Should be a control
1936 // element.
1937 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromChildIndex(4),
1938 UIA_IsControlElementPropertyId, true);
1939
1940 // Generic container, ignored but focusable (id=7). Should not be a control
1941 // element.
1942 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromChildIndex(5),
1943 UIA_IsControlElementPropertyId, false);
1944
1945 // Generic container, invisible and ignored, but focusable (id=8). Should not
1946 // be a control element.
1947 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromChildIndex(6),
1948 UIA_IsControlElementPropertyId, false);
1949}

◆ TEST_F() [161/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetPropertyValueIsDialog   
)

Definition at line 1840 of file ax_platform_node_win_unittest.cc.

1840 {
1842 root.id = 1;
1844 root.child_ids = {2, 3};
1845
1846 AXNodeData alert_dialog;
1847 alert_dialog.id = 2;
1848 alert_dialog.role = ax::mojom::Role::kAlertDialog;
1849
1850 AXNodeData dialog;
1851 dialog.id = 3;
1852 dialog.role = ax::mojom::Role::kDialog;
1853
1854 Init(root, alert_dialog, dialog);
1855
1856 EXPECT_UIA_BOOL_EQ(GetRootIRawElementProviderSimple(), UIA_IsDialogPropertyId,
1857 false);
1858 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromChildIndex(0),
1859 UIA_IsDialogPropertyId, true);
1860 EXPECT_UIA_BOOL_EQ(GetIRawElementProviderSimpleFromChildIndex(1),
1861 UIA_IsDialogPropertyId, true);
1862}

◆ TEST_F() [162/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetProviderOptions   
)

Definition at line 2557 of file ax_platform_node_win_unittest.cc.

2557 {
2558 AXNodeData root_data;
2559 root_data.id = 1;
2560 Init(root_data);
2561
2562 ComPtr<IRawElementProviderSimple> root_node =
2563 GetRootIRawElementProviderSimple();
2564
2565 ProviderOptions provider_options = static_cast<ProviderOptions>(0);
2566 EXPECT_HRESULT_SUCCEEDED(root_node->get_ProviderOptions(&provider_options));
2567 EXPECT_EQ(ProviderOptions_ServerSideProvider |
2568 ProviderOptions_UseComThreading |
2569 ProviderOptions_RefuseNonClientSupport |
2570 ProviderOptions_HasNativeIAccessible,
2571 provider_options);
2572}

◆ TEST_F() [163/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetRuntimeId   
)

Definition at line 2660 of file ax_platform_node_win_unittest.cc.

2660 {
2661 AXNodeData root_data;
2662 root_data.id = 1;
2663 Init(root_data);
2664
2665 ComPtr<IRawElementProviderFragment> root_provider =
2666 GetRootIRawElementProviderFragment();
2667
2668 base::win::ScopedSafearray runtime_id;
2669 EXPECT_HRESULT_SUCCEEDED(root_provider->GetRuntimeId(runtime_id.Receive()));
2670
2671 LONG array_lower_bound;
2672 EXPECT_HRESULT_SUCCEEDED(
2673 ::SafeArrayGetLBound(runtime_id.Get(), 1, &array_lower_bound));
2674 EXPECT_EQ(0, array_lower_bound);
2675
2676 LONG array_upper_bound;
2677 EXPECT_HRESULT_SUCCEEDED(
2678 ::SafeArrayGetUBound(runtime_id.Get(), 1, &array_upper_bound));
2679 EXPECT_EQ(1, array_upper_bound);
2680
2681 int* array_data;
2682 EXPECT_HRESULT_SUCCEEDED(::SafeArrayAccessData(
2683 runtime_id.Get(), reinterpret_cast<void**>(&array_data)));
2684 EXPECT_EQ(UiaAppendRuntimeId, array_data[0]);
2685 EXPECT_NE(-1, array_data[1]);
2686
2687 EXPECT_HRESULT_SUCCEEDED(::SafeArrayUnaccessData(runtime_id.Get()));
2688}

◆ TEST_F() [164/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAItemStatusPropertyId   
)

Definition at line 2032 of file ax_platform_node_win_unittest.cc.

2032 {
2034 root.id = 1;
2036
2037 AXNodeData row1;
2038 row1.id = 2;
2041 static_cast<int>(ax::mojom::SortDirection::kAscending));
2042 root.child_ids.push_back(row1.id);
2043
2044 AXNodeData header1;
2045 header1.id = 3;
2047 header1.AddIntAttribute(
2049 static_cast<int>(ax::mojom::SortDirection::kAscending));
2050 row1.child_ids.push_back(header1.id);
2051
2052 AXNodeData header2;
2053 header2.id = 4;
2055 header2.AddIntAttribute(
2057 static_cast<int>(ax::mojom::SortDirection::kDescending));
2058 row1.child_ids.push_back(header2.id);
2059
2060 AXNodeData header3;
2061 header3.id = 5;
2064 static_cast<int>(ax::mojom::SortDirection::kOther));
2065 row1.child_ids.push_back(header3.id);
2066
2067 AXNodeData header4;
2068 header4.id = 6;
2070 header4.AddIntAttribute(
2072 static_cast<int>(ax::mojom::SortDirection::kUnsorted));
2073 row1.child_ids.push_back(header4.id);
2074
2075 Init(root, row1, header1, header2, header3, header4);
2076
2077 auto* row_node = GetRootAsAXNode()->children()[0];
2078
2079 EXPECT_UIA_BSTR_EQ(QueryInterfaceFromNode<IRawElementProviderSimple>(
2080 row_node->children()[0]),
2081 UIA_ItemStatusPropertyId, L"ascending");
2082
2083 EXPECT_UIA_BSTR_EQ(QueryInterfaceFromNode<IRawElementProviderSimple>(
2084 row_node->children()[1]),
2085 UIA_ItemStatusPropertyId, L"descending");
2086
2087 EXPECT_UIA_BSTR_EQ(QueryInterfaceFromNode<IRawElementProviderSimple>(
2088 row_node->children()[2]),
2089 UIA_ItemStatusPropertyId, L"other");
2090
2091 EXPECT_UIA_VALUE_EQ(QueryInterfaceFromNode<IRawElementProviderSimple>(
2092 row_node->children()[3]),
2093 UIA_ItemStatusPropertyId, ScopedVariant::kEmptyVariant);
2094
2096 QueryInterfaceFromNode<IRawElementProviderSimple>(row_node),
2097 UIA_ItemStatusPropertyId, ScopedVariant::kEmptyVariant);
2098}

◆ TEST_F() [165/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAIWindowProviderGetIsModalFalse   
)

Definition at line 2704 of file ax_platform_node_win_unittest.cc.

2704 {
2706 root.id = 1;
2708 root.AddBoolAttribute(ax::mojom::BoolAttribute::kModal, false);
2709 Init(root);
2710
2711 ComPtr<IRawElementProviderSimple> raw_element_provider_simple =
2712 GetRootIRawElementProviderSimple();
2713 ComPtr<IWindowProvider> window_provider;
2714 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
2715 UIA_WindowPatternId, &window_provider));
2716 ASSERT_NE(nullptr, window_provider.Get());
2717
2718 BOOL is_modal;
2719 EXPECT_HRESULT_SUCCEEDED(window_provider->get_IsModal(&is_modal));
2720 ASSERT_FALSE(is_modal);
2721}

◆ TEST_F() [166/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAIWindowProviderGetIsModalTrue   
)

Definition at line 2723 of file ax_platform_node_win_unittest.cc.

2723 {
2725 root.id = 1;
2727 root.AddBoolAttribute(ax::mojom::BoolAttribute::kModal, true);
2728 Init(root);
2729
2730 ComPtr<IRawElementProviderSimple> raw_element_provider_simple =
2731 GetRootIRawElementProviderSimple();
2732 ComPtr<IWindowProvider> window_provider;
2733 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
2734 UIA_WindowPatternId, &window_provider));
2735 ASSERT_NE(nullptr, window_provider.Get());
2736
2737 BOOL is_modal;
2738 EXPECT_HRESULT_SUCCEEDED(window_provider->get_IsModal(&is_modal));
2739 ASSERT_TRUE(is_modal);
2740}

◆ TEST_F() [167/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAIWindowProviderGetIsModalUnset   
)

Definition at line 2690 of file ax_platform_node_win_unittest.cc.

2690 {
2692 root.id = 1;
2694 Init(root);
2695
2696 ComPtr<IRawElementProviderSimple> raw_element_provider_simple =
2697 GetRootIRawElementProviderSimple();
2698 ComPtr<IWindowProvider> window_provider;
2699 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
2700 UIA_WindowPatternId, &window_provider));
2701 ASSERT_EQ(nullptr, window_provider.Get());
2702}

◆ TEST_F() [168/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAIWindowProviderInvalidArgument   
)

Definition at line 2742 of file ax_platform_node_win_unittest.cc.

2742 {
2744 root.id = 1;
2746 root.AddBoolAttribute(ax::mojom::BoolAttribute::kModal, true);
2747 Init(root);
2748
2749 ComPtr<IRawElementProviderSimple> raw_element_provider_simple =
2750 GetRootIRawElementProviderSimple();
2751 ComPtr<IWindowProvider> window_provider;
2752 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
2753 UIA_WindowPatternId, &window_provider));
2754 ASSERT_NE(nullptr, window_provider.Get());
2755
2756 ASSERT_EQ(E_INVALIDARG, window_provider->WaitForInputIdle(0, nullptr));
2757 ASSERT_EQ(E_INVALIDARG, window_provider->get_CanMaximize(nullptr));
2758 ASSERT_EQ(E_INVALIDARG, window_provider->get_CanMinimize(nullptr));
2759 ASSERT_EQ(E_INVALIDARG, window_provider->get_IsModal(nullptr));
2760 ASSERT_EQ(E_INVALIDARG, window_provider->get_WindowVisualState(nullptr));
2761 ASSERT_EQ(E_INVALIDARG, window_provider->get_WindowInteractionState(nullptr));
2762 ASSERT_EQ(E_INVALIDARG, window_provider->get_IsTopmost(nullptr));
2763}

◆ TEST_F() [169/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAIWindowProviderNotSupported   
)

Definition at line 2765 of file ax_platform_node_win_unittest.cc.

2765 {
2767 root.id = 1;
2769 root.AddBoolAttribute(ax::mojom::BoolAttribute::kModal, true);
2770 Init(root);
2771
2772 ComPtr<IRawElementProviderSimple> raw_element_provider_simple =
2773 GetRootIRawElementProviderSimple();
2774 ComPtr<IWindowProvider> window_provider;
2775 EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
2776 UIA_WindowPatternId, &window_provider));
2777 ASSERT_NE(nullptr, window_provider.Get());
2778
2779 BOOL bool_result;
2780 WindowVisualState window_visual_state_result;
2781 WindowInteractionState window_interaction_state_result;
2782
2783 ASSERT_EQ(static_cast<HRESULT>(UIA_E_NOTSUPPORTED),
2784 window_provider->SetVisualState(
2785 WindowVisualState::WindowVisualState_Normal));
2786 ASSERT_EQ(static_cast<HRESULT>(UIA_E_NOTSUPPORTED), window_provider->Close());
2787 ASSERT_EQ(static_cast<HRESULT>(UIA_E_NOTSUPPORTED),
2788 window_provider->WaitForInputIdle(0, &bool_result));
2789 ASSERT_EQ(static_cast<HRESULT>(UIA_E_NOTSUPPORTED),
2790 window_provider->get_CanMaximize(&bool_result));
2791 ASSERT_EQ(static_cast<HRESULT>(UIA_E_NOTSUPPORTED),
2792 window_provider->get_CanMinimize(&bool_result));
2793 ASSERT_EQ(
2794 static_cast<HRESULT>(UIA_E_NOTSUPPORTED),
2795 window_provider->get_WindowVisualState(&window_visual_state_result));
2796 ASSERT_EQ(static_cast<HRESULT>(UIA_E_NOTSUPPORTED),
2797 window_provider->get_WindowInteractionState(
2798 &window_interaction_state_result));
2799 ASSERT_EQ(static_cast<HRESULT>(UIA_E_NOTSUPPORTED),
2800 window_provider->get_IsTopmost(&bool_result));
2801}

◆ TEST_F() [170/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIALandmarkType   
)

Definition at line 3079 of file ax_platform_node_win_unittest.cc.

3079 {
3080 auto TestLandmarkType = [this](ax::mojom::Role node_role,
3081 std::optional<LONG> expected_landmark_type,
3082 const std::string& node_name = {}) {
3083 AXNodeData root_data;
3084 root_data.id = 1;
3085 root_data.role = node_role;
3086 if (!node_name.empty())
3087 root_data.SetName(node_name);
3088 Init(root_data);
3089
3090 ComPtr<IRawElementProviderSimple> root_provider =
3091 GetRootIRawElementProviderSimple();
3092
3093 if (expected_landmark_type) {
3094 EXPECT_UIA_INT_EQ(root_provider, UIA_LandmarkTypePropertyId,
3095 expected_landmark_type.value());
3096 } else {
3097 EXPECT_UIA_EMPTY(root_provider, UIA_LandmarkTypePropertyId);
3098 }
3099 };
3100
3101 TestLandmarkType(ax::mojom::Role::kBanner, UIA_CustomLandmarkTypeId);
3102 TestLandmarkType(ax::mojom::Role::kComplementary, UIA_CustomLandmarkTypeId);
3103 TestLandmarkType(ax::mojom::Role::kContentInfo, UIA_CustomLandmarkTypeId);
3104 TestLandmarkType(ax::mojom::Role::kFooter, UIA_CustomLandmarkTypeId);
3105 TestLandmarkType(ax::mojom::Role::kMain, UIA_MainLandmarkTypeId);
3106 TestLandmarkType(ax::mojom::Role::kNavigation, UIA_NavigationLandmarkTypeId);
3107 TestLandmarkType(ax::mojom::Role::kSearch, UIA_SearchLandmarkTypeId);
3108
3109 // Only named forms should be exposed as landmarks.
3110 TestLandmarkType(ax::mojom::Role::kForm, {});
3111 TestLandmarkType(ax::mojom::Role::kForm, UIA_FormLandmarkTypeId, "name");
3112
3113 // Only named regions should be exposed as landmarks.
3114 TestLandmarkType(ax::mojom::Role::kRegion, {});
3115 TestLandmarkType(ax::mojom::Role::kRegion, UIA_CustomLandmarkTypeId, "name");
3116
3117 TestLandmarkType(ax::mojom::Role::kGroup, {});
3118 TestLandmarkType(ax::mojom::Role::kHeading, {});
3119 TestLandmarkType(ax::mojom::Role::kList, {});
3120 TestLandmarkType(ax::mojom::Role::kTable, {});
3121}
#define EXPECT_UIA_EMPTY(node, property_id)

◆ TEST_F() [171/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIALocalizedLandmarkType   
)

Definition at line 3123 of file ax_platform_node_win_unittest.cc.

3123 {
3124 auto TestLocalizedLandmarkType =
3125 [this](ax::mojom::Role node_role,
3126 const std::wstring& expected_localized_landmark,
3127 const std::string& node_name = {}) {
3128 AXNodeData root_data;
3129 root_data.id = 1;
3130 root_data.role = node_role;
3131 if (!node_name.empty())
3132 root_data.SetName(node_name);
3133 Init(root_data);
3134
3135 ComPtr<IRawElementProviderSimple> root_provider =
3136 GetRootIRawElementProviderSimple();
3137
3138 if (expected_localized_landmark.empty()) {
3139 EXPECT_UIA_EMPTY(root_provider, UIA_LocalizedLandmarkTypePropertyId);
3140 } else {
3141 EXPECT_UIA_BSTR_EQ(root_provider, UIA_LocalizedLandmarkTypePropertyId,
3142 expected_localized_landmark.c_str());
3143 }
3144 };
3145
3146 TestLocalizedLandmarkType(ax::mojom::Role::kBanner, L"banner");
3147 TestLocalizedLandmarkType(ax::mojom::Role::kComplementary, L"complementary");
3148 TestLocalizedLandmarkType(ax::mojom::Role::kContentInfo,
3149 L"content information");
3150 TestLocalizedLandmarkType(ax::mojom::Role::kFooter, L"content information");
3151
3152 // Only named regions should be exposed as landmarks.
3153 TestLocalizedLandmarkType(ax::mojom::Role::kRegion, {});
3154 TestLocalizedLandmarkType(ax::mojom::Role::kRegion, L"region", "name");
3155
3156 TestLocalizedLandmarkType(ax::mojom::Role::kForm, {});
3157 TestLocalizedLandmarkType(ax::mojom::Role::kGroup, {});
3158 TestLocalizedLandmarkType(ax::mojom::Role::kHeading, {});
3159 TestLocalizedLandmarkType(ax::mojom::Role::kList, {});
3160 TestLocalizedLandmarkType(ax::mojom::Role::kMain, {});
3161 TestLocalizedLandmarkType(ax::mojom::Role::kNavigation, {});
3162 TestLocalizedLandmarkType(ax::mojom::Role::kSearch, {});
3163 TestLocalizedLandmarkType(ax::mojom::Role::kTable, {});
3164}

◆ TEST_F() [172/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIANavigate   
)

Definition at line 2803 of file ax_platform_node_win_unittest.cc.

2803 {
2804 AXNodeData root_data;
2805 root_data.id = 1;
2806
2807 AXNodeData element1_data;
2808 element1_data.id = 2;
2809 root_data.child_ids.push_back(element1_data.id);
2810
2811 AXNodeData element2_data;
2812 element2_data.id = 3;
2813 root_data.child_ids.push_back(element2_data.id);
2814
2815 AXNodeData element3_data;
2816 element3_data.id = 4;
2817 element1_data.child_ids.push_back(element3_data.id);
2818
2819 Init(root_data, element1_data, element2_data, element3_data);
2820
2821 AXNode* root_node = GetRootAsAXNode();
2822 AXNode* element1_node = root_node->children()[0];
2823 AXNode* element2_node = root_node->children()[1];
2824 AXNode* element3_node = element1_node->children()[0];
2825
2826 auto TestNavigate = [this](AXNode* element_node, AXNode* parent,
2827 AXNode* next_sibling, AXNode* prev_sibling,
2828 AXNode* first_child, AXNode* last_child) {
2829 ComPtr<IRawElementProviderFragment> element_provider =
2830 QueryInterfaceFromNode<IRawElementProviderFragment>(element_node);
2831
2832 auto TestNavigateSingle = [&](NavigateDirection direction,
2833 AXNode* expected_node) {
2834 ComPtr<IRawElementProviderFragment> expected_provider =
2835 QueryInterfaceFromNode<IRawElementProviderFragment>(expected_node);
2836
2837 ComPtr<IRawElementProviderFragment> navigated_to_fragment;
2838 EXPECT_HRESULT_SUCCEEDED(
2839 element_provider->Navigate(direction, &navigated_to_fragment));
2840 EXPECT_EQ(expected_provider.Get(), navigated_to_fragment.Get());
2841 };
2842
2843 TestNavigateSingle(NavigateDirection_Parent, parent);
2844 TestNavigateSingle(NavigateDirection_NextSibling, next_sibling);
2845 TestNavigateSingle(NavigateDirection_PreviousSibling, prev_sibling);
2846 TestNavigateSingle(NavigateDirection_FirstChild, first_child);
2847 TestNavigateSingle(NavigateDirection_LastChild, last_child);
2848 };
2849
2850 TestNavigate(root_node,
2851 nullptr, // Parent
2852 nullptr, // NextSibling
2853 nullptr, // PreviousSibling
2854 element1_node, // FirstChild
2855 element2_node); // LastChild
2856
2857 TestNavigate(element1_node, root_node, element2_node, nullptr, element3_node,
2858 element3_node);
2859
2860 TestNavigate(element2_node, root_node, nullptr, element1_node, nullptr,
2861 nullptr);
2862
2863 TestNavigate(element3_node, element1_node, nullptr, nullptr, nullptr,
2864 nullptr);
2865}

◆ TEST_F() [173/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTextPositionAfterCharacter   
)

Definition at line 5824 of file ax_node_position_unittest.cc.

5824 {
5826 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
5828 ASSERT_NE(nullptr, text_position);
5829 ASSERT_TRUE(text_position->IsTextPosition());
5830 TestPositionType test_position =
5831 text_position->AsLeafTextPositionAfterCharacter();
5832 EXPECT_NE(nullptr, test_position);
5833 EXPECT_TRUE(test_position->IsNullPosition());
5834
5835 text_position = AXNodePosition::CreateTextPosition(
5836 GetTreeID(), inline_box1_.id, 5 /* text_offset */,
5838 ASSERT_NE(nullptr, text_position);
5839 ASSERT_TRUE(text_position->IsTextPosition());
5840 test_position = text_position->AsLeafTextPositionAfterCharacter();
5841 EXPECT_NE(nullptr, test_position);
5842 EXPECT_TRUE(test_position->IsTextPosition());
5843 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
5844 EXPECT_EQ(5, test_position->text_offset());
5845
5846 text_position = AXNodePosition::CreateTextPosition(
5847 GetTreeID(), line_break_.id, 1 /* text_offset */,
5849 ASSERT_NE(nullptr, text_position);
5850 ASSERT_TRUE(text_position->IsTextPosition());
5851 test_position = text_position->AsLeafTextPositionAfterCharacter();
5852 EXPECT_NE(nullptr, test_position);
5853 EXPECT_TRUE(test_position->IsTextPosition());
5854 EXPECT_EQ(line_break_.id, test_position->anchor_id());
5855 EXPECT_EQ(1, test_position->text_offset());
5856
5857 text_position = AXNodePosition::CreateTextPosition(
5858 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
5860 ASSERT_NE(nullptr, text_position);
5861 ASSERT_TRUE(text_position->IsTextPosition());
5862 test_position = text_position->AsLeafTextPositionAfterCharacter();
5863 EXPECT_NE(nullptr, test_position);
5864 EXPECT_TRUE(test_position->IsTextPosition());
5865 EXPECT_EQ(line_break_.id, test_position->anchor_id());
5866 EXPECT_EQ(1, test_position->text_offset());
5867
5868 text_position = AXNodePosition::CreateTextPosition(
5869 GetTreeID(), root_.id, 0 /* text_offset */,
5871 ASSERT_NE(nullptr, text_position);
5872 ASSERT_TRUE(text_position->IsTextPosition());
5873 test_position = text_position->AsLeafTextPositionAfterCharacter();
5874 EXPECT_NE(nullptr, test_position);
5875 EXPECT_TRUE(test_position->IsNullPosition());
5876}
std::unique_ptr< AXPosition< AXNodePosition, AXNode > > TestPositionType

◆ TEST_F() [174/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTextPositionAfterCharacterNoAdjustment   
)

Definition at line 5686 of file ax_node_position_unittest.cc.

5686 {
5687 // A text offset that is after "Line 2".
5689 GetTreeID(), root_.id, 13 /* text_offset */,
5691 ASSERT_NE(nullptr, text_position);
5692 ASSERT_TRUE(text_position->IsTextPosition());
5693 TestPositionType test_position =
5694 text_position->AsLeafTextPositionAfterCharacter();
5695 EXPECT_NE(nullptr, test_position);
5696 EXPECT_TRUE(test_position->IsTextPosition());
5697 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5698 EXPECT_EQ(6, test_position->text_offset());
5699
5700 // A text offset that is before "Line 2".
5701 text_position = AXNodePosition::CreateTextPosition(
5702 GetTreeID(), root_.id, 7 /* text_offset */,
5704 ASSERT_NE(nullptr, text_position);
5705 ASSERT_TRUE(text_position->IsTextPosition());
5706 test_position = text_position->AsLeafTextPositionAfterCharacter();
5707 EXPECT_NE(nullptr, test_position);
5708 EXPECT_TRUE(test_position->IsTextPosition());
5709 EXPECT_EQ(line_break_.id, test_position->anchor_id());
5710 EXPECT_EQ(1, test_position->text_offset());
5711
5712 // A text offset that is on the line break right after "Line 1".
5713 text_position = AXNodePosition::CreateTextPosition(
5714 GetTreeID(), text_field_.id, 6 /* text_offset */,
5716 ASSERT_NE(nullptr, text_position);
5717 ASSERT_TRUE(text_position->IsTextPosition());
5718 test_position = text_position->AsLeafTextPositionAfterCharacter();
5719 EXPECT_NE(nullptr, test_position);
5720 EXPECT_TRUE(test_position->IsTextPosition());
5721 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
5722 EXPECT_EQ(6, test_position->text_offset());
5723 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
5724
5725 text_position = AXNodePosition::CreateTextPosition(
5726 GetTreeID(), text_field_.id, 13 /* text_offset */,
5728 ASSERT_NE(nullptr, text_position);
5729 ASSERT_TRUE(text_position->IsTextPosition());
5730 test_position = text_position->AsLeafTextPositionAfterCharacter();
5731 EXPECT_NE(nullptr, test_position);
5732 EXPECT_TRUE(test_position->IsTextPosition());
5733 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5734 EXPECT_EQ(6, test_position->text_offset());
5735
5736 text_position = AXNodePosition::CreateTextPosition(
5737 GetTreeID(), line_break_.id, 0 /* text_offset */,
5739 ASSERT_NE(nullptr, text_position);
5740 ASSERT_TRUE(text_position->IsTextPosition());
5741 test_position = text_position->AsLeafTextPositionAfterCharacter();
5742 EXPECT_NE(nullptr, test_position);
5743 EXPECT_TRUE(test_position->IsTextPosition());
5744 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
5745 EXPECT_EQ(6, test_position->text_offset());
5746
5747 text_position = AXNodePosition::CreateTextPosition(
5748 GetTreeID(), line_break_.id, 1 /* text_offset */,
5750 ASSERT_NE(nullptr, text_position);
5751 ASSERT_TRUE(text_position->IsTextPosition());
5752 test_position = text_position->AsLeafTextPositionAfterCharacter();
5753 EXPECT_NE(nullptr, test_position);
5754 EXPECT_TRUE(test_position->IsTextPosition());
5755 EXPECT_EQ(line_break_.id, test_position->anchor_id());
5756 EXPECT_EQ(1, test_position->text_offset());
5757
5758 text_position = AXNodePosition::CreateTextPosition(
5759 GetTreeID(), inline_box2_.id, 6 /* text_offset */,
5761 ASSERT_NE(nullptr, text_position);
5762 ASSERT_TRUE(text_position->IsTextPosition());
5763 test_position = text_position->AsLeafTextPositionAfterCharacter();
5764 EXPECT_NE(nullptr, test_position);
5765 EXPECT_TRUE(test_position->IsTextPosition());
5766 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5767 EXPECT_EQ(6, test_position->text_offset());
5768}

◆ TEST_F() [175/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTextPositionBeforeAndAfterCharacterAtInvalidGraphemeBoundary   
)

Definition at line 5568 of file ax_node_position_unittest.cc.

5569 {
5570#if true
5571 GTEST_SKIP()
5572 << "Skipping, current accessibility library cannot handle grapheme";
5573#else
5574 std::vector<int> text_offsets;
5575 SetTree(CreateMultilingualDocument(&text_offsets));
5576
5578 GetTreeID(), GetTree()->root()->id(), 4 /* text_offset */,
5580 test_position = test_position->AsLeafTextPositionAfterCharacter();
5581 ASSERT_NE(nullptr, test_position);
5582 EXPECT_TRUE(test_position->IsTextPosition());
5583 EXPECT_EQ(GetTree()->root()->children()[1]->id(), test_position->anchor_id());
5584 // "text_offset_" should have been adjusted to the next grapheme boundary.
5585 EXPECT_EQ(2, test_position->text_offset());
5586 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
5587
5588 test_position = AXNodePosition::CreateTextPosition(
5589 GetTreeID(), GetTree()->root()->id(), 10 /* text_offset */,
5591 test_position = test_position->AsLeafTextPositionBeforeCharacter();
5592 ASSERT_NE(nullptr, test_position);
5593 EXPECT_TRUE(test_position->IsTextPosition());
5594 EXPECT_EQ(GetTree()->root()->children()[2]->id(), test_position->anchor_id());
5595 // "text_offset_" should have been adjusted to the previous grapheme boundary.
5596 EXPECT_EQ(0, test_position->text_offset());
5597 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
5598
5599 test_position = AXNodePosition::CreateTextPosition(
5600 GetTreeID(), GetTree()->root()->id(), 10 /* text_offset */,
5602 test_position = test_position->AsLeafTextPositionBeforeCharacter();
5603 ASSERT_NE(nullptr, test_position);
5604 EXPECT_TRUE(test_position->IsTextPosition());
5605 EXPECT_EQ(GetTree()->root()->children()[2]->id(), test_position->anchor_id());
5606 // The same as above, "text_offset_" should have been adjusted to the previous
5607 // grapheme boundary.
5608 EXPECT_EQ(0, test_position->text_offset());
5609 // An upstream affinity should have had no effect on the outcome and so, it
5610 // should have been reset in order to provide consistent output from the
5611 // method regardless of input affinity.
5612 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
5613#endif // true
5614}

◆ TEST_F() [176/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTextPositionBeforeAndAfterCharacterWithNullPosition   
)

Definition at line 5554 of file ax_node_position_unittest.cc.

5555 {
5556 TestPositionType null_position = AXNodePosition::CreateNullPosition();
5557 ASSERT_NE(nullptr, null_position);
5558 ASSERT_TRUE(null_position->IsNullPosition());
5559 TestPositionType test_position =
5560 null_position->AsLeafTextPositionBeforeCharacter();
5561 EXPECT_NE(nullptr, test_position);
5562 EXPECT_TRUE(test_position->IsNullPosition());
5563 test_position = null_position->AsLeafTextPositionAfterCharacter();
5564 EXPECT_NE(nullptr, test_position);
5565 EXPECT_TRUE(test_position->IsNullPosition());
5566}

◆ TEST_F() [177/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTextPositionBeforeCharacter   
)

Definition at line 5770 of file ax_node_position_unittest.cc.

5770 {
5772 GetTreeID(), inline_box1_.id, 3 /* text_offset */,
5774 ASSERT_NE(nullptr, text_position);
5775 ASSERT_TRUE(text_position->IsTextPosition());
5776 TestPositionType test_position =
5777 text_position->AsLeafTextPositionBeforeCharacter();
5778 EXPECT_NE(nullptr, test_position);
5779 EXPECT_TRUE(test_position->IsTextPosition());
5780 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
5781 EXPECT_EQ(3, test_position->text_offset());
5782
5783 text_position = AXNodePosition::CreateTextPosition(
5784 GetTreeID(), line_break_.id, 1 /* text_offset */,
5786 ASSERT_NE(nullptr, text_position);
5787 ASSERT_TRUE(text_position->IsTextPosition());
5788 test_position = text_position->AsLeafTextPositionBeforeCharacter();
5789 EXPECT_NE(nullptr, test_position);
5790 EXPECT_TRUE(test_position->IsTextPosition());
5791 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5792 EXPECT_EQ(0, test_position->text_offset());
5793
5794 text_position = AXNodePosition::CreateTextPosition(
5795 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
5797 ASSERT_NE(nullptr, text_position);
5798 ASSERT_TRUE(text_position->IsTextPosition());
5799 test_position = text_position->AsLeafTextPositionBeforeCharacter();
5800 EXPECT_NE(nullptr, test_position);
5801 EXPECT_TRUE(test_position->IsTextPosition());
5802 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5803 EXPECT_EQ(0, test_position->text_offset());
5804
5805 text_position = AXNodePosition::CreateTextPosition(
5806 GetTreeID(), inline_box2_.id, 6 /* text_offset */,
5808 ASSERT_NE(nullptr, text_position);
5809 ASSERT_TRUE(text_position->IsTextPosition());
5810 test_position = text_position->AsLeafTextPositionBeforeCharacter();
5811 EXPECT_NE(nullptr, test_position);
5812 EXPECT_TRUE(test_position->IsNullPosition());
5813
5814 text_position = AXNodePosition::CreateTextPosition(
5815 GetTreeID(), root_.id, 13 /* text_offset */,
5817 ASSERT_NE(nullptr, text_position);
5818 ASSERT_TRUE(text_position->IsTextPosition());
5819 test_position = text_position->AsLeafTextPositionBeforeCharacter();
5820 EXPECT_NE(nullptr, test_position);
5821 EXPECT_TRUE(test_position->IsNullPosition());
5822}

◆ TEST_F() [178/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTextPositionBeforeCharacterNoAdjustment   
)

Definition at line 5616 of file ax_node_position_unittest.cc.

5616 {
5617 // A text offset that is on the line break right after "Line 1".
5619 GetTreeID(), root_.id, 6 /* text_offset */,
5621 ASSERT_NE(nullptr, text_position);
5622 ASSERT_TRUE(text_position->IsTextPosition());
5623 TestPositionType test_position =
5624 text_position->AsLeafTextPositionBeforeCharacter();
5625 EXPECT_NE(nullptr, test_position);
5626 EXPECT_TRUE(test_position->IsTextPosition());
5627 EXPECT_EQ(line_break_.id, test_position->anchor_id());
5628 EXPECT_EQ(0, test_position->text_offset());
5629
5630 // A text offset that is before the line break right after "Line 1".
5631 text_position = AXNodePosition::CreateTextPosition(
5632 GetTreeID(), text_field_.id, 6 /* text_offset */,
5634 ASSERT_NE(nullptr, text_position);
5635 ASSERT_TRUE(text_position->IsTextPosition());
5636 test_position = text_position->AsLeafTextPositionBeforeCharacter();
5637 EXPECT_NE(nullptr, test_position);
5638 EXPECT_TRUE(test_position->IsTextPosition());
5639 EXPECT_EQ(line_break_.id, test_position->anchor_id());
5640 EXPECT_EQ(0, test_position->text_offset());
5641 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
5642
5643 text_position = AXNodePosition::CreateTextPosition(
5644 GetTreeID(), text_field_.id, 13 /* text_offset */,
5646 ASSERT_NE(nullptr, text_position);
5647 ASSERT_TRUE(text_position->IsTextPosition());
5648 test_position = text_position->AsLeafTextPositionBeforeCharacter();
5649 EXPECT_NE(nullptr, test_position);
5650 EXPECT_TRUE(test_position->IsNullPosition());
5651
5652 text_position = AXNodePosition::CreateTextPosition(
5653 GetTreeID(), static_text1_.id, 6 /* text_offset */,
5655 ASSERT_NE(nullptr, text_position);
5656 ASSERT_TRUE(text_position->IsTextPosition());
5657 test_position = text_position->AsLeafTextPositionBeforeCharacter();
5658 EXPECT_NE(nullptr, test_position);
5659 EXPECT_TRUE(test_position->IsTextPosition());
5660 EXPECT_EQ(line_break_.id, test_position->anchor_id());
5661 EXPECT_EQ(0, test_position->text_offset());
5662
5663 text_position = AXNodePosition::CreateTextPosition(
5664 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
5666 ASSERT_NE(nullptr, text_position);
5667 ASSERT_TRUE(text_position->IsTextPosition());
5668 test_position = text_position->AsLeafTextPositionBeforeCharacter();
5669 EXPECT_NE(nullptr, test_position);
5670 EXPECT_TRUE(test_position->IsTextPosition());
5671 EXPECT_EQ(line_break_.id, test_position->anchor_id());
5672 EXPECT_EQ(0, test_position->text_offset());
5673
5674 text_position = AXNodePosition::CreateTextPosition(
5675 GetTreeID(), line_break_.id, 1 /* text_offset */,
5677 ASSERT_NE(nullptr, text_position);
5678 ASSERT_TRUE(text_position->IsTextPosition());
5679 test_position = text_position->AsLeafTextPositionBeforeCharacter();
5680 EXPECT_NE(nullptr, test_position);
5681 EXPECT_TRUE(test_position->IsTextPosition());
5682 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5683 EXPECT_EQ(0, test_position->text_offset());
5684}

◆ TEST_F() [179/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTextPositionWithNullPosition   
)

Definition at line 3218 of file ax_node_position_unittest.cc.

3218 {
3219 TestPositionType null_position = AXNodePosition::CreateNullPosition();
3220 ASSERT_NE(nullptr, null_position);
3221 TestPositionType test_position = null_position->AsLeafTextPosition();
3222 ASSERT_NE(nullptr, test_position);
3223 EXPECT_TRUE(test_position->IsNullPosition());
3224}

◆ TEST_F() [180/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTextPositionWithTextPosition   
)

Definition at line 3267 of file ax_node_position_unittest.cc.

3267 {
3268 // Create a text position pointing to the end of the root (an "after text"
3269 // position).
3271 GetTreeID(), root_.id, 13 /* text_offset */,
3273 ASSERT_NE(nullptr, text_position);
3274 ASSERT_TRUE(text_position->IsTextPosition());
3275 ASSERT_FALSE(text_position->IsLeafTextPosition());
3276 TestPositionType test_position = text_position->AsLeafTextPosition();
3277 ASSERT_NE(nullptr, test_position);
3278 EXPECT_TRUE(test_position->IsLeafTextPosition());
3279 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3280 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
3281 EXPECT_EQ(6, test_position->text_offset());
3282 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3283
3284 text_position = AXNodePosition::CreateTextPosition(
3285 GetTreeID(), root_.id, 0 /* text_offset */,
3287 ASSERT_NE(nullptr, text_position);
3288 test_position = text_position->AsLeafTextPosition();
3289 ASSERT_NE(nullptr, test_position);
3290 EXPECT_TRUE(test_position->IsTextPosition());
3291 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3292 EXPECT_EQ(button_.id, test_position->anchor_id());
3293 EXPECT_EQ(0, test_position->text_offset());
3294 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3295
3296 text_position = AXNodePosition::CreateTextPosition(
3297 GetTreeID(), text_field_.id, 0 /* text_offset */,
3299 ASSERT_NE(nullptr, text_position);
3300 test_position = text_position->AsLeafTextPosition();
3301 ASSERT_NE(nullptr, test_position);
3302 EXPECT_TRUE(test_position->IsLeafTextPosition());
3303 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3304 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3305 EXPECT_EQ(0, test_position->text_offset());
3306 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3307
3308 text_position = AXNodePosition::CreateTextPosition(
3309 GetTreeID(), text_field_.id, 0 /* text_offset */,
3311 ASSERT_NE(nullptr, text_position);
3312 test_position = text_position->AsLeafTextPosition();
3313 ASSERT_NE(nullptr, test_position);
3314 EXPECT_TRUE(test_position->IsLeafTextPosition());
3315 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3316 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3317 EXPECT_EQ(0, test_position->text_offset());
3318 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3319
3320 // Create a text position on the root, pointing to the line break character
3321 // inside the text field but with an upstream affinity which will cause the
3322 // leaf text position to be placed after the text of the first inline text
3323 // box.
3324 text_position = AXNodePosition::CreateTextPosition(
3325 GetTreeID(), root_.id, 6 /* text_offset */,
3327 ASSERT_NE(nullptr, text_position);
3328 test_position = text_position->AsLeafTextPosition();
3329 ASSERT_NE(nullptr, test_position);
3330 EXPECT_TRUE(test_position->IsLeafTextPosition());
3331 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3332 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3333 EXPECT_EQ(6, test_position->text_offset());
3334 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3335
3336 // Create a text position pointing to the line break character inside the text
3337 // field but with an upstream affinity which will cause the leaf text position
3338 // to be placed after the text of the first inline text box.
3339 text_position = AXNodePosition::CreateTextPosition(
3340 GetTreeID(), text_field_.id, 6 /* text_offset */,
3342 ASSERT_NE(nullptr, text_position);
3343 test_position = text_position->AsLeafTextPosition();
3344 ASSERT_NE(nullptr, test_position);
3345 EXPECT_TRUE(test_position->IsLeafTextPosition());
3346 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3347 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3348 EXPECT_EQ(6, test_position->text_offset());
3349 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3350
3351 // Create a text position on the root, pointing to the line break character
3352 // inside the text field.
3353 text_position = AXNodePosition::CreateTextPosition(
3354 GetTreeID(), root_.id, 6 /* text_offset */,
3356 ASSERT_NE(nullptr, text_position);
3357 test_position = text_position->AsLeafTextPosition();
3358 ASSERT_NE(nullptr, test_position);
3359 EXPECT_TRUE(test_position->IsLeafTextPosition());
3360 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3361 EXPECT_EQ(line_break_.id, test_position->anchor_id());
3362 EXPECT_EQ(0, test_position->text_offset());
3363 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3364
3365 // Create a text position pointing to the line break character inside the text
3366 // field.
3367 text_position = AXNodePosition::CreateTextPosition(
3368 GetTreeID(), text_field_.id, 6 /* text_offset */,
3370 ASSERT_NE(nullptr, text_position);
3371 test_position = text_position->AsLeafTextPosition();
3372 ASSERT_NE(nullptr, test_position);
3373 EXPECT_TRUE(test_position->IsLeafTextPosition());
3374 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3375 EXPECT_EQ(line_break_.id, test_position->anchor_id());
3376 EXPECT_EQ(0, test_position->text_offset());
3377 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3378
3379 // Create a text position pointing to the offset after the last character in
3380 // the text field, (an "after text" position).
3381 text_position = AXNodePosition::CreateTextPosition(
3382 GetTreeID(), text_field_.id, 13 /* text_offset */,
3384 ASSERT_NE(nullptr, text_position);
3385 test_position = text_position->AsLeafTextPosition();
3386 ASSERT_NE(nullptr, test_position);
3387 EXPECT_TRUE(test_position->IsLeafTextPosition());
3388 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3389 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
3390 EXPECT_EQ(6, test_position->text_offset());
3391 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3392
3393 // Create a root text position that points to the middle of a leaf text
3394 // position, should maintain its relative text_offset ("Lin<e> 2")
3395 text_position = AXNodePosition::CreateTextPosition(
3396 GetTreeID(), root_.id, 10 /* text_offset */,
3398 ASSERT_NE(nullptr, text_position);
3399 test_position = text_position->AsLeafTextPosition();
3400 ASSERT_NE(nullptr, test_position);
3401 EXPECT_TRUE(test_position->IsLeafTextPosition());
3402 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3403 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
3404 EXPECT_EQ(3, test_position->text_offset());
3405 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3406
3407 // Create a root text position that points to the middle of an equivalent leaf
3408 // text position. It should maintain its relative text_offset ("Lin<e> 2")
3409 text_position = AXNodePosition::CreateTextPosition(
3410 GetTreeID(), root_.id, 10 /* text_offset */,
3412 ASSERT_NE(nullptr, text_position);
3413 test_position = text_position->AsLeafTextPosition();
3414 ASSERT_NE(nullptr, test_position);
3415 EXPECT_TRUE(test_position->IsLeafTextPosition());
3416 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3417 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
3418 EXPECT_EQ(3, test_position->text_offset());
3419 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3420}

◆ TEST_F() [181/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTextPositionWithTextPositionAndEmptyTextSandwich   
)

Definition at line 3422 of file ax_node_position_unittest.cc.

3422 {
3423 // This test updates the tree structure to test a specific edge case -
3424 // AsLeafTextPosition when there is an empty leaf text node between
3425 // two non-empty text nodes.
3426 AXNodeData root_data;
3427 root_data.id = 1;
3429
3430 AXNodeData text_data;
3431 text_data.id = 2;
3433 text_data.SetName("some text");
3434
3435 AXNodeData button_data;
3436 button_data.id = 3;
3437 button_data.role = ax::mojom::Role::kButton;
3438 button_data.SetName("");
3439
3440 AXNodeData more_text_data;
3441 more_text_data.id = 4;
3442 more_text_data.role = ax::mojom::Role::kInlineTextBox;
3443 more_text_data.SetName("more text");
3444
3445 root_data.child_ids = {text_data.id, button_data.id, more_text_data.id};
3446
3447 SetTree(CreateAXTree({root_data, text_data, button_data, more_text_data}));
3448
3449 // Create a text position on the root pointing to just after the
3450 // first static text leaf node.
3452 GetTreeID(), root_data.id, 9 /* text_offset */,
3454 ASSERT_NE(nullptr, text_position);
3455 ASSERT_TRUE(text_position->IsTextPosition());
3456 ASSERT_FALSE(text_position->IsLeafTextPosition());
3457 TestPositionType test_position = text_position->AsLeafTextPosition();
3458 ASSERT_NE(nullptr, test_position);
3459 EXPECT_TRUE(test_position->IsLeafTextPosition());
3460 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3461 EXPECT_EQ(button_data.id, test_position->anchor_id());
3462 EXPECT_EQ(0, test_position->text_offset());
3463 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3464
3465 text_position = AXNodePosition::CreateTextPosition(
3466 GetTreeID(), root_data.id, 9 /* text_offset */,
3468 ASSERT_NE(nullptr, text_position);
3469 test_position = text_position->AsLeafTextPosition();
3470 ASSERT_NE(nullptr, test_position);
3471 EXPECT_TRUE(test_position->IsLeafTextPosition());
3472 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3473 EXPECT_EQ(text_data.id, test_position->anchor_id());
3474 EXPECT_EQ(9, test_position->text_offset());
3475 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3476}

◆ TEST_F() [182/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTextPositionWithTreePosition   
)

Definition at line 3226 of file ax_node_position_unittest.cc.

3226 {
3227 // Create a tree position pointing to the first static text node inside the
3228 // text field.
3229 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
3230 GetTreeID(), text_field_.id, 0 /* child_index */);
3231 ASSERT_NE(nullptr, tree_position);
3232 TestPositionType test_position = tree_position->AsLeafTextPosition();
3233 ASSERT_NE(nullptr, test_position);
3234 EXPECT_TRUE(test_position->IsLeafTextPosition());
3235 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3236 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3237 EXPECT_EQ(0, test_position->text_offset());
3238 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3239
3240 // Create a tree position pointing to the line break node inside the text
3241 // field.
3242 tree_position = AXNodePosition::CreateTreePosition(
3243 GetTreeID(), text_field_.id, 1 /* child_index */);
3244 ASSERT_NE(nullptr, tree_position);
3245 test_position = tree_position->AsLeafTextPosition();
3246 ASSERT_NE(nullptr, test_position);
3247 EXPECT_TRUE(test_position->IsLeafTextPosition());
3248 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3249 EXPECT_EQ(line_break_.id, test_position->anchor_id());
3250 EXPECT_EQ(0, test_position->text_offset());
3251 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3252
3253 // Create a text position pointing to the second static text node inside the
3254 // text field.
3255 tree_position = AXNodePosition::CreateTreePosition(
3256 GetTreeID(), text_field_.id, 2 /* child_index */);
3257 ASSERT_NE(nullptr, tree_position);
3258 test_position = tree_position->AsLeafTextPosition();
3259 ASSERT_NE(nullptr, test_position);
3260 EXPECT_TRUE(test_position->IsLeafTextPosition());
3261 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3262 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
3263 EXPECT_EQ(0, test_position->text_offset());
3264 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3265}

◆ TEST_F() [183/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTreePositionWithNullPosition   
)

Definition at line 3038 of file ax_node_position_unittest.cc.

3038 {
3039 TestPositionType null_position = AXNodePosition::CreateNullPosition();
3040 ASSERT_NE(nullptr, null_position);
3041 TestPositionType test_position = null_position->AsLeafTreePosition();
3042 ASSERT_NE(nullptr, test_position);
3043 EXPECT_TRUE(test_position->IsNullPosition());
3044}

◆ TEST_F() [184/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTreePositionWithTextPosition   
)

Definition at line 3084 of file ax_node_position_unittest.cc.

3084 {
3085 // Create a text position pointing to the end of the root (an "after text"
3086 // position).
3088 GetTreeID(), root_.id, 13 /* text_offset */,
3090 ASSERT_NE(nullptr, text_position);
3091 ASSERT_TRUE(text_position->IsTextPosition());
3092 TestPositionType test_position = text_position->AsLeafTreePosition();
3093 ASSERT_NE(nullptr, test_position);
3094 EXPECT_TRUE(test_position->IsLeafTreePosition());
3095 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3096 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
3097 EXPECT_EQ(0, test_position->child_index());
3098
3099 text_position = AXNodePosition::CreateTextPosition(
3100 GetTreeID(), root_.id, 0 /* text_offset */,
3102 ASSERT_NE(nullptr, text_position);
3103 ASSERT_TRUE(text_position->IsTextPosition());
3104 test_position = text_position->AsLeafTreePosition();
3105 ASSERT_NE(nullptr, test_position);
3106 EXPECT_TRUE(test_position->IsLeafTreePosition());
3107 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3108 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3109 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3110
3111 text_position = AXNodePosition::CreateTextPosition(
3112 GetTreeID(), text_field_.id, 0 /* text_offset */,
3114 ASSERT_NE(nullptr, text_position);
3115 ASSERT_TRUE(text_position->IsTextPosition());
3116 test_position = text_position->AsLeafTreePosition();
3117 ASSERT_NE(nullptr, test_position);
3118 EXPECT_TRUE(test_position->IsLeafTreePosition());
3119 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3120 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3121 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3122
3123 text_position = AXNodePosition::CreateTextPosition(
3124 GetTreeID(), text_field_.id, 0 /* text_offset */,
3126 ASSERT_NE(nullptr, text_position);
3127 ASSERT_TRUE(text_position->IsTextPosition());
3128 test_position = text_position->AsLeafTreePosition();
3129 ASSERT_NE(nullptr, test_position);
3130 EXPECT_TRUE(test_position->IsLeafTreePosition());
3131 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3132 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3133 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3134
3135 // Create a text position on the root, pointing to the line break character
3136 // inside the text field but with an upstream affinity which will cause the
3137 // leaf text position to be placed after the text of the first inline text
3138 // box.
3139 text_position = AXNodePosition::CreateTextPosition(
3140 GetTreeID(), root_.id, 6 /* text_offset */,
3142 ASSERT_NE(nullptr, text_position);
3143 ASSERT_TRUE(text_position->IsTextPosition());
3144 test_position = text_position->AsLeafTreePosition();
3145 ASSERT_NE(nullptr, test_position);
3146 EXPECT_TRUE(test_position->IsLeafTreePosition());
3147 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3148 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3149 EXPECT_EQ(0, test_position->child_index());
3150
3151 // Create a text position pointing to the line break character inside the text
3152 // field but with an upstream affinity which will cause the leaf text position
3153 // to be placed after the text of the first inline text box.
3154 text_position = AXNodePosition::CreateTextPosition(
3155 GetTreeID(), text_field_.id, 6 /* text_offset */,
3157 ASSERT_NE(nullptr, text_position);
3158 test_position = text_position->AsLeafTreePosition();
3159 ASSERT_NE(nullptr, test_position);
3160 EXPECT_TRUE(test_position->IsLeafTreePosition());
3161 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3162 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3163 EXPECT_EQ(0, test_position->child_index());
3164
3165 // Create a text position on the root, pointing to the line break character
3166 // inside the text field.
3167 text_position = AXNodePosition::CreateTextPosition(
3168 GetTreeID(), root_.id, 6 /* text_offset */,
3170 ASSERT_NE(nullptr, text_position);
3171 test_position = text_position->AsLeafTreePosition();
3172 ASSERT_NE(nullptr, test_position);
3173 EXPECT_TRUE(test_position->IsLeafTreePosition());
3174 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3175 EXPECT_EQ(line_break_.id, test_position->anchor_id());
3176 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3177
3178 // Create a text position pointing to the line break character inside the text
3179 // field.
3180 text_position = AXNodePosition::CreateTextPosition(
3181 GetTreeID(), text_field_.id, 6 /* text_offset */,
3183 ASSERT_NE(nullptr, text_position);
3184 test_position = text_position->AsLeafTreePosition();
3185 ASSERT_NE(nullptr, test_position);
3186 EXPECT_TRUE(test_position->IsLeafTreePosition());
3187 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3188 EXPECT_EQ(line_break_.id, test_position->anchor_id());
3189 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3190
3191 // Create a text position pointing to the offset after the last character in
3192 // the text field, (an "after text" position).
3193 text_position = AXNodePosition::CreateTextPosition(
3194 GetTreeID(), text_field_.id, 13 /* text_offset */,
3196 ASSERT_NE(nullptr, text_position);
3197 test_position = text_position->AsLeafTreePosition();
3198 ASSERT_NE(nullptr, test_position);
3199 EXPECT_TRUE(test_position->IsLeafTreePosition());
3200 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3201 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
3202 EXPECT_EQ(0, test_position->child_index());
3203
3204 // Create a root text position that points to the middle of an equivalent leaf
3205 // text position.
3206 text_position = AXNodePosition::CreateTextPosition(
3207 GetTreeID(), root_.id, 10 /* text_offset */,
3209 ASSERT_NE(nullptr, text_position);
3210 test_position = text_position->AsLeafTreePosition();
3211 ASSERT_NE(nullptr, test_position);
3212 EXPECT_TRUE(test_position->IsLeafTreePosition());
3213 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3214 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
3215 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3216}

◆ TEST_F() [185/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTreePositionWithTreePosition   
)

Definition at line 3046 of file ax_node_position_unittest.cc.

3046 {
3047 // Create a tree position pointing to the first static text node inside the
3048 // text field: a "before children" position.
3049 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
3050 GetTreeID(), text_field_.id, 0 /* child_index */);
3051 ASSERT_NE(nullptr, tree_position);
3052 TestPositionType test_position = tree_position->AsLeafTreePosition();
3053 ASSERT_NE(nullptr, test_position);
3054 EXPECT_TRUE(test_position->IsLeafTreePosition());
3055 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3056 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3057 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3058
3059 // Create a tree position pointing to the line break node inside the text
3060 // field.
3061 tree_position = AXNodePosition::CreateTreePosition(
3062 GetTreeID(), text_field_.id, 1 /* child_index */);
3063 ASSERT_NE(nullptr, tree_position);
3064 test_position = tree_position->AsLeafTreePosition();
3065 ASSERT_NE(nullptr, test_position);
3066 EXPECT_TRUE(test_position->IsLeafTreePosition());
3067 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3068 EXPECT_EQ(line_break_.id, test_position->anchor_id());
3069 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3070
3071 // Create a text position pointing to the second static text node inside the
3072 // text field.
3073 tree_position = AXNodePosition::CreateTreePosition(
3074 GetTreeID(), text_field_.id, 2 /* child_index */);
3075 ASSERT_NE(nullptr, tree_position);
3076 test_position = tree_position->AsLeafTreePosition();
3077 ASSERT_NE(nullptr, test_position);
3078 EXPECT_TRUE(test_position->IsLeafTreePosition());
3079 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3080 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
3081 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3082}

◆ TEST_F() [186/325]

ui::TEST_F ( AXPositionTest  ,
AsTextPositionWithNullPosition   
)

Definition at line 2966 of file ax_node_position_unittest.cc.

2966 {
2967 TestPositionType null_position = AXNodePosition::CreateNullPosition();
2968 ASSERT_NE(nullptr, null_position);
2969 TestPositionType test_position = null_position->AsTextPosition();
2970 ASSERT_NE(nullptr, test_position);
2971 EXPECT_TRUE(test_position->IsNullPosition());
2972}

◆ TEST_F() [187/325]

ui::TEST_F ( AXPositionTest  ,
AsTextPositionWithTextPosition   
)

Definition at line 3022 of file ax_node_position_unittest.cc.

3022 {
3024 GetTreeID(), text_field_.id, 0 /* text_offset */,
3026 ASSERT_NE(nullptr, text_position);
3027 ASSERT_TRUE(text_position->IsTextPosition());
3028 TestPositionType test_position = text_position->AsTextPosition();
3029 ASSERT_NE(nullptr, test_position);
3030 EXPECT_TRUE(test_position->IsTextPosition());
3031 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3032 EXPECT_EQ(text_field_.id, test_position->anchor_id());
3033 EXPECT_EQ(0, test_position->text_offset());
3034 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3035 EXPECT_EQ(AXNodePosition::INVALID_INDEX, test_position->child_index());
3036}

◆ TEST_F() [188/325]

ui::TEST_F ( AXPositionTest  ,
AsTextPositionWithTreePosition   
)

Definition at line 2974 of file ax_node_position_unittest.cc.

2974 {
2975 // Create a tree position pointing to the line break node inside the text
2976 // field.
2977 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
2978 GetTreeID(), text_field_.id, 1 /* child_index */);
2979 ASSERT_NE(nullptr, tree_position);
2980 TestPositionType test_position = tree_position->AsTextPosition();
2981 ASSERT_NE(nullptr, test_position);
2982 EXPECT_TRUE(test_position->IsTextPosition());
2983 EXPECT_EQ(GetTreeID(), test_position->tree_id());
2984 EXPECT_EQ(text_field_.id, test_position->anchor_id());
2985 // The created text position should point to the 6th character inside the text
2986 // field, i.e. the line break.
2987 EXPECT_EQ(6, test_position->text_offset());
2988 // But its child index should be unchanged.
2989 EXPECT_EQ(1, test_position->child_index());
2990 // And the affinity cannot be anything other than downstream because we
2991 // haven't moved up the tree and so there was no opportunity to introduce any
2992 // ambiguity regarding the new position.
2993 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
2994
2995 // Test for a "before text" position.
2996 tree_position = AXNodePosition::CreateTreePosition(
2997 GetTreeID(), inline_box1_.id, AXNodePosition::BEFORE_TEXT);
2998 ASSERT_NE(nullptr, tree_position);
2999 test_position = tree_position->AsTextPosition();
3000 ASSERT_NE(nullptr, test_position);
3001 EXPECT_TRUE(test_position->IsTextPosition());
3002 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3003 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3004 EXPECT_EQ(0, test_position->text_offset());
3005 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3006 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3007
3008 // Test for an "after text" position.
3009 tree_position = AXNodePosition::CreateTreePosition(
3010 GetTreeID(), inline_box1_.id, 0 /* child_index */);
3011 ASSERT_NE(nullptr, tree_position);
3012 test_position = tree_position->AsTextPosition();
3013 ASSERT_NE(nullptr, test_position);
3014 EXPECT_TRUE(test_position->IsTextPosition());
3015 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3016 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3017 EXPECT_EQ(6, test_position->text_offset());
3018 EXPECT_EQ(0, test_position->child_index());
3019 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3020}

◆ TEST_F() [189/325]

ui::TEST_F ( AXPositionTest  ,
AsTreePositionWithNullPosition   
)

Definition at line 2898 of file ax_node_position_unittest.cc.

2898 {
2899 TestPositionType null_position = AXNodePosition::CreateNullPosition();
2900 ASSERT_NE(nullptr, null_position);
2901 TestPositionType test_position = null_position->AsTreePosition();
2902 ASSERT_NE(nullptr, test_position);
2903 EXPECT_TRUE(test_position->IsNullPosition());
2904}

◆ TEST_F() [190/325]

ui::TEST_F ( AXPositionTest  ,
AsTreePositionWithTextPosition   
)

Definition at line 2919 of file ax_node_position_unittest.cc.

2919 {
2920 // Create a text position pointing to the last character in the text field.
2922 GetTreeID(), text_field_.id, 12 /* text_offset */,
2924 ASSERT_NE(nullptr, text_position);
2925 ASSERT_TRUE(text_position->IsTextPosition());
2926 TestPositionType test_position = text_position->AsTreePosition();
2927 ASSERT_NE(nullptr, test_position);
2928 EXPECT_TRUE(test_position->IsTreePosition());
2929 EXPECT_EQ(GetTreeID(), test_position->tree_id());
2930 EXPECT_EQ(text_field_.id, test_position->anchor_id());
2931 // The created tree position should point to the second static text node
2932 // inside the text field.
2933 EXPECT_EQ(2, test_position->child_index());
2934 // But its text offset should be unchanged.
2935 EXPECT_EQ(12, test_position->text_offset());
2936
2937 // Test for a "before text" position.
2938 text_position = AXNodePosition::CreateTextPosition(
2939 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
2941 ASSERT_NE(nullptr, text_position);
2942 ASSERT_TRUE(text_position->IsTextPosition());
2943 test_position = text_position->AsTreePosition();
2944 ASSERT_NE(nullptr, test_position);
2945 EXPECT_TRUE(test_position->IsTreePosition());
2946 EXPECT_EQ(GetTreeID(), test_position->tree_id());
2947 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
2948 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
2949 EXPECT_EQ(0, test_position->text_offset());
2950
2951 // Test for an "after text" position.
2952 text_position = AXNodePosition::CreateTextPosition(
2953 GetTreeID(), inline_box2_.id, 6 /* text_offset */,
2955 ASSERT_NE(nullptr, text_position);
2956 ASSERT_TRUE(text_position->IsTextPosition());
2957 test_position = text_position->AsTreePosition();
2958 ASSERT_NE(nullptr, test_position);
2959 EXPECT_TRUE(test_position->IsTreePosition());
2960 EXPECT_EQ(GetTreeID(), test_position->tree_id());
2961 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
2962 EXPECT_EQ(0, test_position->child_index());
2963 EXPECT_EQ(6, test_position->text_offset());
2964}

◆ TEST_F() [191/325]

ui::TEST_F ( AXPositionTest  ,
AsTreePositionWithTreePosition   
)

Definition at line 2906 of file ax_node_position_unittest.cc.

2906 {
2907 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
2908 GetTreeID(), root_.id, 1 /* child_index */);
2909 ASSERT_NE(nullptr, tree_position);
2910 TestPositionType test_position = tree_position->AsTreePosition();
2911 ASSERT_NE(nullptr, test_position);
2912 EXPECT_TRUE(test_position->IsTreePosition());
2913 EXPECT_EQ(GetTreeID(), test_position->tree_id());
2914 EXPECT_EQ(root_.id, test_position->anchor_id());
2915 EXPECT_EQ(1, test_position->child_index());
2916 EXPECT_EQ(AXNodePosition::INVALID_OFFSET, test_position->text_offset());
2917}

◆ TEST_F() [192/325]

ui::TEST_F ( AXPositionTest  ,
AsUnignoredPosition   
)

Definition at line 3478 of file ax_node_position_unittest.cc.

3478 {
3479 AXNodeData root_data;
3480 root_data.id = 1;
3482
3483 AXNodeData static_text_data_1;
3484 static_text_data_1.id = 2;
3485 static_text_data_1.role = ax::mojom::Role::kStaticText;
3486 static_text_data_1.SetName("12");
3487
3488 AXNodeData inline_box_data_1;
3489 inline_box_data_1.id = 3;
3490 inline_box_data_1.role = ax::mojom::Role::kInlineTextBox;
3491 inline_box_data_1.SetName("1");
3492
3493 AXNodeData inline_box_data_2;
3494 inline_box_data_2.id = 4;
3495 inline_box_data_2.role = ax::mojom::Role::kInlineTextBox;
3496 inline_box_data_2.SetName("2");
3497 inline_box_data_2.AddState(ax::mojom::State::kIgnored);
3498
3499 AXNodeData container_data;
3500 container_data.id = 5;
3502 container_data.AddState(ax::mojom::State::kIgnored);
3503
3504 AXNodeData static_text_data_2;
3505 static_text_data_2.id = 6;
3506 static_text_data_2.role = ax::mojom::Role::kStaticText;
3507 static_text_data_2.SetName("3");
3508
3509 AXNodeData inline_box_data_3;
3510 inline_box_data_3.id = 7;
3511 inline_box_data_3.role = ax::mojom::Role::kInlineTextBox;
3512 inline_box_data_3.SetName("3");
3513
3514 static_text_data_1.child_ids = {inline_box_data_1.id, inline_box_data_2.id};
3515 container_data.child_ids = {static_text_data_2.id};
3516 static_text_data_2.child_ids = {inline_box_data_3.id};
3517 root_data.child_ids = {static_text_data_1.id, container_data.id};
3518
3519 SetTree(CreateAXTree({root_data, static_text_data_1, inline_box_data_1,
3520 inline_box_data_2, container_data, static_text_data_2,
3521 inline_box_data_3}));
3522
3523 // 1. In the case of a text position, we move up the parent positions until we
3524 // find the next unignored equivalent parent position. We don't do this for
3525 // tree positions because, unlike text positions which maintain the
3526 // corresponding text offset in the inner text of the parent node, tree
3527 // positions would lose some information every time a parent position is
3528 // computed. In other words, the parent position of a tree position is, in
3529 // most cases, non-equivalent to the child position.
3530
3531 // "Before text" position.
3533 GetTreeID(), container_data.id, 0 /* text_offset */,
3535 ASSERT_TRUE(text_position->IsIgnored());
3536 TestPositionType test_position = text_position->AsUnignoredPosition(
3537 AXPositionAdjustmentBehavior::kMoveForward);
3538 ASSERT_NE(nullptr, test_position);
3539 EXPECT_TRUE(test_position->IsTextPosition());
3540 EXPECT_EQ(root_data.id, test_position->anchor_id());
3541 EXPECT_EQ(2, test_position->text_offset());
3542 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3543
3544 // "After text" position.
3545 text_position = AXNodePosition::CreateTextPosition(
3546 GetTreeID(), container_data.id, 1 /* text_offset */,
3548 ASSERT_TRUE(text_position->IsIgnored());
3549 // Changing the adjustment behavior should not affect the outcome.
3550 test_position = text_position->AsUnignoredPosition(
3551 AXPositionAdjustmentBehavior::kMoveBackward);
3552 ASSERT_NE(nullptr, test_position);
3553 EXPECT_TRUE(test_position->IsTextPosition());
3554 EXPECT_EQ(root_data.id, test_position->anchor_id());
3555 EXPECT_EQ(3, test_position->text_offset());
3556 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3557
3558 // "Before children" position.
3559 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
3560 GetTreeID(), container_data.id, 0 /* child_index */);
3561 ASSERT_TRUE(tree_position->IsIgnored());
3562 test_position = tree_position->AsUnignoredPosition(
3563 AXPositionAdjustmentBehavior::kMoveForward);
3564 ASSERT_NE(nullptr, test_position);
3565 EXPECT_TRUE(test_position->IsTreePosition());
3566 EXPECT_EQ(inline_box_data_3.id, test_position->anchor_id());
3567 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3568
3569 // "After children" position.
3570 tree_position = AXNodePosition::CreateTreePosition(
3571 GetTreeID(), container_data.id, 1 /* child_index */);
3572 ASSERT_TRUE(tree_position->IsIgnored());
3573 // Changing the adjustment behavior should not affect the outcome.
3574 test_position = tree_position->AsUnignoredPosition(
3575 AXPositionAdjustmentBehavior::kMoveBackward);
3576 ASSERT_NE(nullptr, test_position);
3577 EXPECT_TRUE(test_position->IsTreePosition());
3578 EXPECT_EQ(inline_box_data_3.id, test_position->anchor_id());
3579 EXPECT_EQ(0, test_position->child_index());
3580
3581 // "After children" tree positions that are anchored to an unignored node
3582 // whose last child is ignored.
3583 tree_position = AXNodePosition::CreateTreePosition(
3584 GetTreeID(), static_text_data_1.id, 2 /* child_index */);
3585 ASSERT_TRUE(tree_position->IsIgnored());
3586 test_position = tree_position->AsUnignoredPosition(
3587 AXPositionAdjustmentBehavior::kMoveBackward);
3588 ASSERT_NE(nullptr, test_position);
3589 EXPECT_TRUE(test_position->IsTreePosition());
3590 EXPECT_EQ(inline_box_data_1.id, test_position->anchor_id());
3591 EXPECT_EQ(0, test_position->child_index());
3592
3593 // 2. If no equivalent and unignored parent position can be computed, we try
3594 // computing the leaf equivalent position. If this is unignored, we return it.
3595 // This can happen both for tree and text positions, provided that the leaf
3596 // node and its inner text is visible to platform APIs, i.e. it's unignored.
3597
3599 SetTree(CreateAXTree({root_data, static_text_data_1, inline_box_data_1,
3600 inline_box_data_2, container_data, static_text_data_2,
3601 inline_box_data_3}));
3602
3603 text_position = AXNodePosition::CreateTextPosition(
3604 GetTreeID(), root_data.id, 0 /* text_offset */,
3606 ASSERT_TRUE(text_position->IsIgnored());
3607 test_position = text_position->AsUnignoredPosition(
3608 AXPositionAdjustmentBehavior::kMoveForward);
3609 ASSERT_NE(nullptr, test_position);
3610 EXPECT_TRUE(test_position->IsTextPosition());
3611 EXPECT_EQ(inline_box_data_1.id, test_position->anchor_id());
3612 EXPECT_EQ(0, test_position->text_offset());
3613 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3614
3615 text_position = AXNodePosition::CreateTextPosition(
3616 GetTreeID(), root_data.id, 0 /* text_offset */,
3618 ASSERT_TRUE(text_position->IsIgnored());
3619 // Changing the adjustment behavior should not change the outcome.
3620 test_position = text_position->AsUnignoredPosition(
3621 AXPositionAdjustmentBehavior::kMoveBackward);
3622 ASSERT_NE(nullptr, test_position);
3623 EXPECT_TRUE(test_position->IsTextPosition());
3624 EXPECT_EQ(inline_box_data_1.id, test_position->anchor_id());
3625 EXPECT_EQ(0, test_position->text_offset());
3626 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3627
3628 tree_position = AXNodePosition::CreateTreePosition(GetTreeID(), root_data.id,
3629 1 /* child_index */);
3630 ASSERT_TRUE(tree_position->IsIgnored());
3631 test_position = tree_position->AsUnignoredPosition(
3632 AXPositionAdjustmentBehavior::kMoveForward);
3633 ASSERT_NE(nullptr, test_position);
3634 EXPECT_TRUE(test_position->IsTreePosition());
3635 EXPECT_EQ(inline_box_data_3.id, test_position->anchor_id());
3636 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3637
3638 // Changing the adjustment behavior should not affect the outcome.
3639 test_position = tree_position->AsUnignoredPosition(
3640 AXPositionAdjustmentBehavior::kMoveBackward);
3641 ASSERT_NE(nullptr, test_position);
3642 EXPECT_TRUE(test_position->IsTreePosition());
3643 EXPECT_EQ(inline_box_data_3.id, test_position->anchor_id());
3644 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3645
3646 // "After children" position.
3647 tree_position = AXNodePosition::CreateTreePosition(GetTreeID(), root_data.id,
3648 2 /* child_index */);
3649 ASSERT_TRUE(tree_position->IsIgnored());
3650 test_position = tree_position->AsUnignoredPosition(
3651 AXPositionAdjustmentBehavior::kMoveForward);
3652 ASSERT_NE(nullptr, test_position);
3653 EXPECT_TRUE(test_position->IsTreePosition());
3654 EXPECT_EQ(inline_box_data_3.id, test_position->anchor_id());
3655 EXPECT_EQ(0, test_position->child_index());
3656
3657 // Changing the adjustment behavior should not affect the outcome.
3658 test_position = tree_position->AsUnignoredPosition(
3659 AXPositionAdjustmentBehavior::kMoveBackward);
3660 ASSERT_NE(nullptr, test_position);
3661 EXPECT_TRUE(test_position->IsTreePosition());
3662 EXPECT_EQ(inline_box_data_3.id, test_position->anchor_id());
3663 EXPECT_EQ(0, test_position->child_index());
3664
3665 // "Before children" position.
3666 tree_position = AXNodePosition::CreateTreePosition(
3667 GetTreeID(), container_data.id, 0 /* child_index */);
3668 ASSERT_TRUE(tree_position->IsIgnored());
3669 test_position = tree_position->AsUnignoredPosition(
3670 AXPositionAdjustmentBehavior::kMoveForward);
3671 ASSERT_NE(nullptr, test_position);
3672 EXPECT_TRUE(test_position->IsTreePosition());
3673 EXPECT_EQ(inline_box_data_3.id, test_position->anchor_id());
3674 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3675
3676 // "After children" position.
3677 tree_position = AXNodePosition::CreateTreePosition(
3678 GetTreeID(), container_data.id, 1 /* child_index */);
3679 ASSERT_TRUE(tree_position->IsIgnored());
3680 // Changing the adjustment behavior should not affect the outcome.
3681 test_position = tree_position->AsUnignoredPosition(
3682 AXPositionAdjustmentBehavior::kMoveBackward);
3683 ASSERT_NE(nullptr, test_position);
3684 EXPECT_TRUE(test_position->IsTreePosition());
3685 EXPECT_EQ(inline_box_data_3.id, test_position->anchor_id());
3686 EXPECT_EQ(0, test_position->child_index());
3687
3688 // 3. As a last resort, we move either to the next or previous unignored
3689 // position in the accessibility tree, based on the "adjustment_behavior".
3690
3691 text_position = AXNodePosition::CreateTextPosition(
3692 GetTreeID(), root_data.id, 1 /* text_offset */,
3694 ASSERT_TRUE(text_position->IsIgnored());
3695 test_position = text_position->AsUnignoredPosition(
3696 AXPositionAdjustmentBehavior::kMoveForward);
3697 ASSERT_NE(nullptr, test_position);
3698 EXPECT_TRUE(test_position->IsTextPosition());
3699 EXPECT_EQ(inline_box_data_3.id, test_position->anchor_id());
3700 EXPECT_EQ(0, test_position->text_offset());
3701 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3702
3703 text_position = AXNodePosition::CreateTextPosition(
3704 GetTreeID(), inline_box_data_2.id, 0 /* text_offset */,
3706 ASSERT_TRUE(text_position->IsIgnored());
3707 test_position = text_position->AsUnignoredPosition(
3708 AXPositionAdjustmentBehavior::kMoveForward);
3709 ASSERT_NE(nullptr, test_position);
3710 EXPECT_TRUE(test_position->IsTextPosition());
3711 EXPECT_EQ(inline_box_data_3.id, test_position->anchor_id());
3712 EXPECT_EQ(0, test_position->text_offset());
3713 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3714
3715 text_position = AXNodePosition::CreateTextPosition(
3716 GetTreeID(), inline_box_data_2.id, 0 /* text_offset */,
3718 ASSERT_TRUE(text_position->IsIgnored());
3719 test_position = text_position->AsUnignoredPosition(
3720 AXPositionAdjustmentBehavior::kMoveBackward);
3721 ASSERT_NE(nullptr, test_position);
3722 EXPECT_TRUE(test_position->IsTextPosition());
3723 EXPECT_EQ(inline_box_data_1.id, test_position->anchor_id());
3724 // This should be an "after text" position.
3725 EXPECT_EQ(1, test_position->text_offset());
3726 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3727
3728 tree_position = AXNodePosition::CreateTreePosition(
3729 GetTreeID(), inline_box_data_2.id, AXNodePosition::BEFORE_TEXT);
3730 ASSERT_TRUE(tree_position->IsIgnored());
3731 test_position = tree_position->AsUnignoredPosition(
3732 AXPositionAdjustmentBehavior::kMoveForward);
3733 ASSERT_NE(nullptr, test_position);
3734 EXPECT_TRUE(test_position->IsTreePosition());
3735 EXPECT_EQ(inline_box_data_3.id, test_position->anchor_id());
3736 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3737 ASSERT_TRUE(tree_position->IsIgnored());
3738
3739 test_position = tree_position->AsUnignoredPosition(
3740 AXPositionAdjustmentBehavior::kMoveBackward);
3741 ASSERT_NE(nullptr, test_position);
3742 EXPECT_TRUE(test_position->IsTreePosition());
3743 EXPECT_EQ(inline_box_data_1.id, test_position->anchor_id());
3744 EXPECT_EQ(0, test_position->child_index());
3745}

◆ TEST_F() [193/325]

ui::TEST_F ( AXPositionTest  ,
AsValidPosition   
)

Definition at line 5891 of file ax_node_position_unittest.cc.

5891 {
5892 AXNodeData root_data;
5893 root_data.id = 1;
5895
5896 AXNodeData text_data;
5897 text_data.id = 2;
5899 text_data.SetName("some text");
5900
5901 root_data.child_ids = {text_data.id};
5902
5903 SetTree(CreateAXTree({root_data, text_data}));
5904
5905 // Create a text position at MaxTextOffset.
5907 GetTreeID(), text_data.id, 9 /* text_offset */,
5909 ASSERT_NE(nullptr, text_position);
5910 EXPECT_TRUE(text_position->IsTextPosition());
5911 EXPECT_TRUE(text_position->IsValid());
5912 EXPECT_EQ(9, text_position->text_offset());
5913
5914 // Test basic cases with static MaxTextOffset
5915 TestPositionType test_position = text_position->CreateNextCharacterPosition(
5916 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
5917 EXPECT_TRUE(test_position->IsValid());
5918 ASSERT_NE(nullptr, test_position);
5919 EXPECT_TRUE(test_position->IsTextPosition());
5920 EXPECT_EQ(text_data.id, test_position->anchor_id());
5921 EXPECT_EQ(9, test_position->text_offset());
5922 test_position = text_position->CreateNextCharacterPosition(
5923 AXBoundaryBehavior::CrossBoundary);
5924 ASSERT_NE(nullptr, test_position);
5925 EXPECT_TRUE(test_position->IsNullPosition());
5926
5927 // AsValidPosition should not change any fields on already-valid positions.
5928 EXPECT_TRUE(text_position->IsValid());
5929 test_position = text_position->AsValidPosition();
5930 EXPECT_TRUE(test_position->IsValid());
5931 EXPECT_EQ(*test_position, *text_position);
5932
5933 // Now make a change to shorten MaxTextOffset. Ensure that this position is
5934 // invalid, then call AsValidPosition and ensure that it is now valid.
5935 text_data.SetName("some tex");
5936 AXTreeUpdate shorten_text_update;
5937 shorten_text_update.nodes = {text_data};
5938 ASSERT_TRUE(GetTree()->Unserialize(shorten_text_update));
5939
5940 EXPECT_FALSE(text_position->IsValid());
5941 text_position = text_position->AsValidPosition();
5942 EXPECT_TRUE(text_position->IsValid());
5943 EXPECT_EQ(8, text_position->text_offset());
5944
5945 // Now repeat the prior tests and ensure that we can create next character
5946 // positions with the new, valid MaxTextOffset (8).
5947 test_position = text_position->CreateNextCharacterPosition(
5948 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
5949 EXPECT_TRUE(test_position->IsValid());
5950 ASSERT_NE(nullptr, test_position);
5951 EXPECT_TRUE(test_position->IsTextPosition());
5952 EXPECT_EQ(text_data.id, test_position->anchor_id());
5953 EXPECT_EQ(8, test_position->text_offset());
5954 test_position = text_position->CreateNextCharacterPosition(
5955 AXBoundaryBehavior::CrossBoundary);
5956 ASSERT_NE(nullptr, test_position);
5957 EXPECT_TRUE(test_position->IsNullPosition());
5958
5959 // AsValidPosition should create a NullPosition if a position's anchor is
5960 // removed. This is true for both tree positions and text positions.
5961 EXPECT_TRUE(text_position->IsValid());
5962 TestPositionType tree_position = text_position->AsTreePosition();
5963 ASSERT_NE(nullptr, tree_position);
5964 EXPECT_TRUE(tree_position->IsTreePosition());
5965 EXPECT_TRUE(tree_position->IsValid());
5966 EXPECT_EQ(0, tree_position->child_index());
5967
5968 AXTreeUpdate remove_node_update;
5969 root_data.child_ids = {};
5970 remove_node_update.nodes = {root_data};
5971 ASSERT_TRUE(GetTree()->Unserialize(remove_node_update));
5972 EXPECT_FALSE(text_position->IsValid());
5973 EXPECT_FALSE(tree_position->IsValid());
5974
5975 text_position = text_position->AsValidPosition();
5976 EXPECT_TRUE(text_position->IsValid());
5977 tree_position = tree_position->AsValidPosition();
5978 EXPECT_TRUE(tree_position->IsValid());
5979
5980 EXPECT_TRUE(text_position->IsNullPosition());
5981 EXPECT_TRUE(tree_position->IsNullPosition());
5982}

◆ TEST_F() [194/325]

ui::TEST_F ( AXPositionTest  ,
AsValidPositionInDescendantOfEmptyObject   
)

Definition at line 5984 of file ax_node_position_unittest.cc.

5984 {
5985 g_ax_embedded_object_behavior = AXEmbeddedObjectBehavior::kExposeCharacter;
5986
5987 // ++1 kRootWebArea
5988 // ++++2 kButton
5989 // ++++++3 kStaticText "3.14" ignored
5990 // ++++++++4 kInlineTextBox "3.14" ignored
5991 AXNodeData root_1;
5992 AXNodeData button_2;
5993 AXNodeData static_text_3;
5994 AXNodeData inline_box_4;
5995
5996 root_1.id = 1;
5997 button_2.id = 2;
5998 static_text_3.id = 3;
5999 inline_box_4.id = 4;
6000
6002 root_1.child_ids = {button_2.id};
6003
6004 button_2.role = ax::mojom::Role::kButton;
6005 button_2.child_ids = {static_text_3.id};
6006
6007 static_text_3.role = ax::mojom::Role::kStaticText;
6008 static_text_3.SetName("3.14");
6009 static_text_3.child_ids = {inline_box_4.id};
6010
6012 inline_box_4.SetName("3.14");
6013
6014 SetTree(CreateAXTree({root_1, button_2, static_text_3, inline_box_4}));
6015
6017 GetTreeID(), inline_box_4.id, 3, ax::mojom::TextAffinity::kDownstream);
6018 ASSERT_NE(nullptr, text_position);
6019 EXPECT_TRUE(text_position->IsTextPosition());
6020 EXPECT_TRUE(text_position->IsValid());
6021 EXPECT_EQ(*text_position, *text_position->AsValidPosition());
6022
6023 TestPositionType tree_position =
6024 AXNodePosition::CreateTreePosition(GetTreeID(), inline_box_4.id, 0);
6025 ASSERT_NE(nullptr, tree_position);
6026 EXPECT_TRUE(tree_position->IsTreePosition());
6027 EXPECT_TRUE(tree_position->IsValid());
6028 EXPECT_EQ(*tree_position, *tree_position->AsValidPosition());
6029
6030 static_text_3.AddState(ax::mojom::State::kIgnored);
6033 update.nodes = {static_text_3, inline_box_4};
6034 ASSERT_TRUE(GetTree()->Unserialize(update));
6035
6036 EXPECT_FALSE(text_position->IsValid());
6037 text_position = text_position->AsValidPosition();
6038 EXPECT_TRUE(text_position->IsValid());
6039 EXPECT_EQ(1, text_position->text_offset());
6040
6041 EXPECT_FALSE(tree_position->IsValid());
6042 tree_position = tree_position->AsValidPosition();
6043 EXPECT_TRUE(tree_position->IsValid());
6044 EXPECT_EQ(0, tree_position->child_index());
6045}
AXEmbeddedObjectBehavior g_ax_embedded_object_behavior

◆ TEST_F() [195/325]

ui::TEST_F ( AXPositionTest  ,
AtEndOfAnchorWithNullPosition   
)

Definition at line 1168 of file ax_node_position_unittest.cc.

1168 {
1169 TestPositionType null_position = AXNodePosition::CreateNullPosition();
1170 ASSERT_NE(nullptr, null_position);
1171 EXPECT_FALSE(null_position->AtEndOfAnchor());
1172}

◆ TEST_F() [196/325]

ui::TEST_F ( AXPositionTest  ,
AtEndOfAnchorWithTextPosition   
)

Definition at line 1191 of file ax_node_position_unittest.cc.

1191 {
1193 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
1195 ASSERT_NE(nullptr, text_position);
1196 ASSERT_TRUE(text_position->IsTextPosition());
1197 EXPECT_TRUE(text_position->AtEndOfAnchor());
1198
1199 text_position = AXNodePosition::CreateTextPosition(
1200 GetTreeID(), inline_box1_.id, 5 /* text_offset */,
1202 ASSERT_NE(nullptr, text_position);
1203 ASSERT_TRUE(text_position->IsTextPosition());
1204 EXPECT_FALSE(text_position->AtEndOfAnchor());
1205
1206 text_position = AXNodePosition::CreateTextPosition(
1207 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
1209 ASSERT_NE(nullptr, text_position);
1210 ASSERT_TRUE(text_position->IsTextPosition());
1211 EXPECT_FALSE(text_position->AtEndOfAnchor());
1212}

◆ TEST_F() [197/325]

ui::TEST_F ( AXPositionTest  ,
AtEndOfAnchorWithTreePosition   
)

Definition at line 1174 of file ax_node_position_unittest.cc.

1174 {
1175 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
1176 GetTreeID(), root_.id, 3 /* child_index */);
1177 ASSERT_NE(nullptr, tree_position);
1178 EXPECT_TRUE(tree_position->AtEndOfAnchor());
1179
1180 tree_position = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
1181 2 /* child_index */);
1182 ASSERT_NE(nullptr, tree_position);
1183 EXPECT_FALSE(tree_position->AtEndOfAnchor());
1184
1185 tree_position = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
1186 0 /* child_index */);
1187 ASSERT_NE(nullptr, tree_position);
1188 EXPECT_FALSE(tree_position->AtEndOfAnchor());
1189}

◆ TEST_F() [198/325]

ui::TEST_F ( AXPositionTest  ,
AtEndOfBlankLine   
)

Definition at line 1397 of file ax_node_position_unittest.cc.

1397 {
1398 // Modify the test tree so that the line break will appear on a line of its
1399 // own, i.e. as creating a blank line.
1400 inline_box1_.RemoveIntAttribute(ax::mojom::IntAttribute::kNextOnLineId);
1401 line_break_.RemoveIntAttribute(ax::mojom::IntAttribute::kPreviousOnLineId);
1403 update.nodes = {inline_box1_, line_break_};
1404 ASSERT_TRUE(GetTree()->Unserialize(update));
1405
1406 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
1407 GetTreeID(), text_field_.id, 1 /* child_index */);
1408 ASSERT_NE(nullptr, tree_position);
1409 ASSERT_TRUE(tree_position->IsTreePosition());
1410 EXPECT_FALSE(tree_position->AtEndOfLine());
1411
1413 GetTreeID(), line_break_.id, 0 /* text_offset */,
1415 ASSERT_NE(nullptr, text_position);
1416 ASSERT_TRUE(text_position->IsTextPosition());
1417 EXPECT_FALSE(text_position->AtEndOfLine());
1418
1419 text_position = AXNodePosition::CreateTextPosition(
1420 GetTreeID(), line_break_.id, 1 /* text_offset */,
1422 ASSERT_NE(nullptr, text_position);
1423 ASSERT_TRUE(text_position->IsTextPosition());
1424 EXPECT_TRUE(text_position->AtEndOfLine());
1425}

◆ TEST_F() [199/325]

ui::TEST_F ( AXPositionTest  ,
AtEndOfLineWithTextPosition   
)

Definition at line 1317 of file ax_node_position_unittest.cc.

1317 {
1319 GetTreeID(), inline_box1_.id, 5 /* text_offset */,
1321 ASSERT_NE(nullptr, text_position);
1322 ASSERT_TRUE(text_position->IsTextPosition());
1323 EXPECT_FALSE(text_position->AtEndOfLine());
1324
1325 text_position = AXNodePosition::CreateTextPosition(
1326 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
1328 ASSERT_NE(nullptr, text_position);
1329 ASSERT_TRUE(text_position->IsTextPosition());
1330 EXPECT_TRUE(text_position->AtEndOfLine());
1331
1332 // A "before text" position anchored at the line break should visually be the
1333 // same as a text position at the end of the previous line.
1334 text_position = AXNodePosition::CreateTextPosition(
1335 GetTreeID(), line_break_.id, 0 /* text_offset */,
1337 ASSERT_NE(nullptr, text_position);
1338 ASSERT_TRUE(text_position->IsTextPosition());
1339 EXPECT_TRUE(text_position->AtEndOfLine());
1340
1341 // The following position comes after the soft line break, so it should not be
1342 // marked as the end of the line.
1343 text_position = AXNodePosition::CreateTextPosition(
1344 GetTreeID(), line_break_.id, 1 /* text_offset */,
1346 ASSERT_NE(nullptr, text_position);
1347 ASSERT_TRUE(text_position->IsTextPosition());
1348 EXPECT_FALSE(text_position->AtEndOfLine());
1349
1350 text_position = AXNodePosition::CreateTextPosition(
1351 GetTreeID(), inline_box2_.id, 5 /* text_offset */,
1353 ASSERT_NE(nullptr, text_position);
1354 ASSERT_TRUE(text_position->IsTextPosition());
1355 EXPECT_FALSE(text_position->AtEndOfLine());
1356
1357 text_position = AXNodePosition::CreateTextPosition(
1358 GetTreeID(), inline_box2_.id, 6 /* text_offset */,
1360 ASSERT_NE(nullptr, text_position);
1361 ASSERT_TRUE(text_position->IsTextPosition());
1362 EXPECT_TRUE(text_position->AtEndOfLine());
1363}

◆ TEST_F() [200/325]

ui::TEST_F ( AXPositionTest  ,
AtEndOfParagraphWithTextPosition   
)

Definition at line 1771 of file ax_node_position_unittest.cc.

1771 {
1772 // End of |inline_box1_| is not the end of paragraph since it's
1773 // followed by a whitespace-only line breaking object
1775 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
1777 ASSERT_NE(nullptr, text_position);
1778 ASSERT_TRUE(text_position->IsTextPosition());
1779 EXPECT_FALSE(text_position->AtEndOfParagraph());
1780
1781 // The start of |line_break_| is not the end of paragraph since it's
1782 // not the end of its anchor.
1783 text_position = AXNodePosition::CreateTextPosition(
1784 GetTreeID(), line_break_.id, 0 /* text_offset */,
1786 ASSERT_NE(nullptr, text_position);
1787 ASSERT_TRUE(text_position->IsTextPosition());
1788 EXPECT_FALSE(text_position->AtEndOfParagraph());
1789
1790 // The end of |line_break_| is the end of paragraph since it's
1791 // a line breaking object without additional trailing whitespace.
1792 text_position = AXNodePosition::CreateTextPosition(
1793 GetTreeID(), line_break_.id, 1 /* text_offset */,
1795 ASSERT_NE(nullptr, text_position);
1796 ASSERT_TRUE(text_position->IsTextPosition());
1797 EXPECT_TRUE(text_position->AtEndOfParagraph());
1798
1799 text_position = AXNodePosition::CreateTextPosition(
1800 GetTreeID(), inline_box2_.id, 5 /* text_offset */,
1802 ASSERT_NE(nullptr, text_position);
1803 ASSERT_TRUE(text_position->IsTextPosition());
1804 EXPECT_FALSE(text_position->AtEndOfParagraph());
1805
1806 // The end of |inline_box2_| is the end of paragraph since it's
1807 // followed by the end of document.
1808 text_position = AXNodePosition::CreateTextPosition(
1809 GetTreeID(), inline_box2_.id, 6 /* text_offset */,
1811 ASSERT_NE(nullptr, text_position);
1812 ASSERT_TRUE(text_position->IsTextPosition());
1813 EXPECT_TRUE(text_position->AtEndOfParagraph());
1814}

◆ TEST_F() [201/325]

ui::TEST_F ( AXPositionTest  ,
AtLastNodeInTree   
)

Definition at line 5119 of file ax_node_position_unittest.cc.

5119 {
5121 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
5123 ASSERT_NE(nullptr, text_position);
5124 EXPECT_FALSE(text_position->AtLastNodeInTree());
5125 EXPECT_FALSE(text_position->AsTreePosition()->AtLastNodeInTree());
5126
5127 TestPositionType test_position =
5128 text_position->CreatePositionAtEndOfDocument();
5129 ASSERT_NE(nullptr, test_position);
5130 EXPECT_TRUE(test_position->AtLastNodeInTree());
5131 EXPECT_TRUE(test_position->AsTreePosition()->AtLastNodeInTree());
5132 EXPECT_FALSE(text_position->CreateNullPosition()->AtLastNodeInTree());
5133
5134 TestPositionType on_last_node_but_not_at_maxtextoffset =
5135 AXNodePosition::CreateTextPosition(GetTreeID(), inline_box2_.id,
5136 1 /* text_offset */,
5138 ASSERT_NE(nullptr, on_last_node_but_not_at_maxtextoffset);
5139 EXPECT_TRUE(on_last_node_but_not_at_maxtextoffset->AtLastNodeInTree());
5140 EXPECT_TRUE(on_last_node_but_not_at_maxtextoffset->AsTreePosition()
5141 ->AtLastNodeInTree());
5142}

◆ TEST_F() [202/325]

ui::TEST_F ( AXPositionTest  ,
AtStartAndEndOfLineInsideTextField   
)

Definition at line 1556 of file ax_node_position_unittest.cc.

1556 {
1557 // This test ensures that "AtStart/EndOfLine" methods work properly when at
1558 // the start or end of a text field.
1559 //
1560 // We set up a test tree with two text fields. The first one has one line of
1561 // text, and the second one three. There are inline text boxes containing only
1562 // white space at the start and end of both text fields, which is a valid
1563 // AXTree that might be generated by our renderer.
1564 AXNodeData root_data;
1565 root_data.id = 1;
1567 // "kIsLineBreakingObject" is not strictly necessary but is added for
1568 // completeness.
1570 true);
1571
1572 AXNodeData text_field_data_1;
1573 text_field_data_1.id = 2;
1574 text_field_data_1.role = ax::mojom::Role::kGroup;
1575 // "kIsLineBreakingObject" and the "kEditable" state are not strictly
1576 // necessary but are added for completeness.
1577 text_field_data_1.AddBoolAttribute(
1579 text_field_data_1.AddState(ax::mojom::State::kEditable);
1580 // Notice that there is one space at the start and one at the end of the text
1581 // field's value.
1582 text_field_data_1.SetValue(" Text field one ");
1583
1584 AXNodeData static_text_data_1;
1585 static_text_data_1.id = 3;
1586 static_text_data_1.role = ax::mojom::Role::kStaticText;
1587 static_text_data_1.SetName(" Text field one ");
1588
1589 AXNodeData inline_box_data_1;
1590 inline_box_data_1.id = 4;
1591 inline_box_data_1.role = ax::mojom::Role::kInlineTextBox;
1592 inline_box_data_1.SetName(" ");
1593
1594 AXNodeData inline_box_data_2;
1595 inline_box_data_2.id = 5;
1596 inline_box_data_2.role = ax::mojom::Role::kInlineTextBox;
1598 inline_box_data_2.id);
1600 inline_box_data_1.id);
1601 inline_box_data_2.SetName("Text field one");
1602
1603 AXNodeData inline_box_data_3;
1604 inline_box_data_3.id = 6;
1605 inline_box_data_3.role = ax::mojom::Role::kInlineTextBox;
1607 inline_box_data_3.id);
1609 inline_box_data_2.id);
1610 inline_box_data_3.SetName(" ");
1611
1612 AXNodeData text_field_data_2;
1613 text_field_data_2.id = 7;
1614 text_field_data_2.role = ax::mojom::Role::kGroup;
1615 // "kIsLineBreakingObject" and the "kEditable" state are not strictly
1616 // necessary but are added for completeness.
1617 text_field_data_2.AddBoolAttribute(
1619 text_field_data_1.AddState(ax::mojom::State::kEditable);
1620 // Notice that there are three lines, the first and the last one include only
1621 // a single space.
1622 text_field_data_2.SetValue(" Text field two ");
1623
1624 AXNodeData static_text_data_2;
1625 static_text_data_2.id = 8;
1626 static_text_data_2.role = ax::mojom::Role::kStaticText;
1627 static_text_data_2.SetName(" Text field two ");
1628
1629 AXNodeData inline_box_data_4;
1630 inline_box_data_4.id = 9;
1631 inline_box_data_4.role = ax::mojom::Role::kInlineTextBox;
1632 inline_box_data_4.SetName(" ");
1633
1634 AXNodeData inline_box_data_5;
1635 inline_box_data_5.id = 10;
1636 inline_box_data_5.role = ax::mojom::Role::kInlineTextBox;
1637 inline_box_data_5.SetName("Text field two");
1638
1639 AXNodeData inline_box_data_6;
1640 inline_box_data_6.id = 11;
1641 inline_box_data_6.role = ax::mojom::Role::kInlineTextBox;
1642 inline_box_data_6.SetName(" ");
1643
1644 static_text_data_1.child_ids = {inline_box_data_1.id, inline_box_data_2.id,
1645 inline_box_data_3.id};
1646 static_text_data_2.child_ids = {inline_box_data_4.id, inline_box_data_5.id,
1647 inline_box_data_6.id};
1648 text_field_data_1.child_ids = {static_text_data_1.id};
1649 text_field_data_2.child_ids = {static_text_data_2.id};
1650 root_data.child_ids = {text_field_data_1.id, text_field_data_2.id};
1651
1652 SetTree(
1653 CreateAXTree({root_data, text_field_data_1, static_text_data_1,
1654 inline_box_data_1, inline_box_data_2, inline_box_data_3,
1655 text_field_data_2, static_text_data_2, inline_box_data_4,
1656 inline_box_data_5, inline_box_data_6}));
1657
1658 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
1659 GetTreeID(), text_field_data_1.id, 0 /* child_index */);
1660 ASSERT_NE(nullptr, tree_position);
1661 ASSERT_TRUE(tree_position->IsTreePosition());
1662 EXPECT_TRUE(tree_position->AtStartOfLine());
1663 EXPECT_FALSE(tree_position->AtEndOfLine());
1664
1665 tree_position = AXNodePosition::CreateTreePosition(
1666 GetTreeID(), text_field_data_1.id, 1 /* child_index */);
1667 ASSERT_NE(nullptr, tree_position);
1668 ASSERT_TRUE(tree_position->IsTreePosition());
1669 EXPECT_FALSE(tree_position->AtStartOfLine());
1670 EXPECT_TRUE(tree_position->AtEndOfLine());
1671
1672 tree_position = AXNodePosition::CreateTreePosition(
1673 GetTreeID(), text_field_data_2.id, 0 /* child_index */);
1674 ASSERT_NE(nullptr, tree_position);
1675 ASSERT_TRUE(tree_position->IsTreePosition());
1676 EXPECT_TRUE(tree_position->AtStartOfLine());
1677 EXPECT_FALSE(tree_position->AtEndOfLine());
1678
1679 tree_position = AXNodePosition::CreateTreePosition(
1680 GetTreeID(), text_field_data_2.id, 1 /* child_index */);
1681 ASSERT_NE(nullptr, tree_position);
1682 ASSERT_TRUE(tree_position->IsTreePosition());
1683 EXPECT_FALSE(tree_position->AtStartOfLine());
1684 EXPECT_TRUE(tree_position->AtEndOfLine());
1685
1687 GetTreeID(), text_field_data_1.id, 0 /* text_offset */,
1689 ASSERT_NE(nullptr, text_position);
1690 ASSERT_TRUE(text_position->IsTextPosition());
1691 EXPECT_TRUE(text_position->AtStartOfLine());
1692 EXPECT_FALSE(text_position->AtEndOfLine());
1693
1694 text_position = AXNodePosition::CreateTextPosition(
1695 GetTreeID(), text_field_data_1.id, 16 /* text_offset */,
1697 ASSERT_NE(nullptr, text_position);
1698 ASSERT_TRUE(text_position->IsTextPosition());
1699 EXPECT_FALSE(text_position->AtStartOfLine());
1700 EXPECT_TRUE(text_position->AtEndOfLine());
1701
1702 text_position = AXNodePosition::CreateTextPosition(
1703 GetTreeID(), text_field_data_2.id, 0 /* text_offset */,
1705 ASSERT_NE(nullptr, text_position);
1706 ASSERT_TRUE(text_position->IsTextPosition());
1707 EXPECT_TRUE(text_position->AtStartOfLine());
1708 EXPECT_FALSE(text_position->AtEndOfLine());
1709
1710 text_position = AXNodePosition::CreateTextPosition(
1711 GetTreeID(), text_field_data_2.id, 16 /* text_offset */,
1713 ASSERT_NE(nullptr, text_position);
1714 ASSERT_TRUE(text_position->IsTextPosition());
1715 EXPECT_FALSE(text_position->AtStartOfLine());
1716 EXPECT_TRUE(text_position->AtEndOfLine());
1717}

◆ TEST_F() [203/325]

ui::TEST_F ( AXPositionTest  ,
AtStartAndEndOfLineWhenAtEndOfTextSpan   
)

Definition at line 1427 of file ax_node_position_unittest.cc.

1427 {
1428 // This test ensures that the "AtStartOfLine" and the "AtEndOfLine" methods
1429 // return false and true respectively when we are at the end of a text span.
1430 //
1431 // A text span is defined by a series of inline text boxes that make up a
1432 // single static text object. Lines always end at the end of static text
1433 // objects, so there would never arise a situation when a position at the end
1434 // of a text span would be at start of line. It should always be at end of
1435 // line. On the contrary, if a position is at the end of an inline text box
1436 // and the equivalent parent position is in the middle of a static text
1437 // object, then the position would sometimes be at start of line, i.e., when
1438 // the inline text box contains only white space that is used to separate
1439 // lines in the case of lines being wrapped by a soft line break.
1440 //
1441 // Example accessibility tree:
1442 // 0:kRootWebArea
1443 // ++1:kStaticText "Hello testing "
1444 // ++++2:kInlineTextBox "Hello" kNextOnLine=2
1445 // ++++3:kInlineTextBox " " kPreviousOnLine=2
1446 // ++++4:kInlineTextBox "testing" kNextOnLine=5
1447 // ++++5:kInlineTextBox " " kPreviousOnLine=4
1448 // ++6:kStaticText "here."
1449 // ++++7:kInlineTextBox "here."
1450 //
1451 // Resulting text representation:
1452 // "Hello<soft_line_break>testing <hard_line_break>here."
1453 // Notice the extra space after the word "testing". This is not a line break.
1454 // The hard line break is caused by the presence of the second static text
1455 // object.
1456 //
1457 // A position at the end of inline text box 3 should be at start of line,
1458 // whilst a position at the end of inline text box 5 should not.
1459
1460 AXNodeData root_data;
1461 root_data.id = 1;
1463 // "kIsLineBreakingObject" is not strictly necessary but is added for
1464 // completeness.
1466 true);
1467
1468 AXNodeData static_text_data_1;
1469 static_text_data_1.id = 2;
1470 static_text_data_1.role = ax::mojom::Role::kStaticText;
1471 static_text_data_1.SetName("Hello testing ");
1472
1473 AXNodeData inline_box_data_1;
1474 inline_box_data_1.id = 3;
1475 inline_box_data_1.role = ax::mojom::Role::kInlineTextBox;
1476 inline_box_data_1.SetName("hello");
1477
1478 AXNodeData inline_box_data_2;
1479 inline_box_data_2.id = 4;
1480 inline_box_data_2.role = ax::mojom::Role::kInlineTextBox;
1482 inline_box_data_2.id);
1484 inline_box_data_1.id);
1485 // The name is a space character that we assume it turns into a soft line
1486 // break by the layout engine.
1487 inline_box_data_2.SetName(" ");
1488
1489 AXNodeData inline_box_data_3;
1490 inline_box_data_3.id = 5;
1491 inline_box_data_3.role = ax::mojom::Role::kInlineTextBox;
1492 inline_box_data_3.SetName("testing");
1493
1494 AXNodeData inline_box_data_4;
1495 inline_box_data_4.id = 6;
1496 inline_box_data_4.role = ax::mojom::Role::kInlineTextBox;
1498 inline_box_data_4.id);
1500 inline_box_data_3.id);
1501 inline_box_data_4.SetName(" "); // Just a space character - not a line break.
1502
1503 AXNodeData static_text_data_2;
1504 static_text_data_2.id = 7;
1505 static_text_data_2.role = ax::mojom::Role::kStaticText;
1506 static_text_data_2.SetName("here.");
1507
1508 AXNodeData inline_box_data_5;
1509 inline_box_data_5.id = 8;
1510 inline_box_data_5.role = ax::mojom::Role::kInlineTextBox;
1511 inline_box_data_5.SetName("here.");
1512
1513 static_text_data_1.child_ids = {inline_box_data_1.id, inline_box_data_2.id,
1514 inline_box_data_3.id, inline_box_data_4.id};
1515 static_text_data_2.child_ids = {inline_box_data_5.id};
1516 root_data.child_ids = {static_text_data_1.id, static_text_data_2.id};
1517
1518 SetTree(CreateAXTree({root_data, static_text_data_1, inline_box_data_1,
1519 inline_box_data_2, inline_box_data_3, inline_box_data_4,
1520 static_text_data_2, inline_box_data_5}));
1521
1522 // An "after text" tree position - after the soft line break.
1523 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
1524 GetTreeID(), inline_box_data_2.id, 0 /* child_index */);
1525 ASSERT_NE(nullptr, tree_position);
1526 ASSERT_TRUE(tree_position->IsTreePosition());
1527 EXPECT_TRUE(tree_position->AtStartOfLine());
1528 EXPECT_FALSE(tree_position->AtEndOfLine());
1529
1530 // An "after text" tree position - after the space character and before the
1531 // hard line break caused by the second static text object.
1532 tree_position = AXNodePosition::CreateTreePosition(
1533 GetTreeID(), inline_box_data_4.id, 0 /* child_index */);
1534 ASSERT_NE(nullptr, tree_position);
1535 ASSERT_TRUE(tree_position->IsTreePosition());
1536 EXPECT_FALSE(tree_position->AtStartOfLine());
1537 EXPECT_TRUE(tree_position->AtEndOfLine());
1538
1540 GetTreeID(), inline_box_data_2.id, 1 /* text_offset */,
1542 ASSERT_NE(nullptr, text_position);
1543 ASSERT_TRUE(text_position->IsTextPosition());
1544 EXPECT_TRUE(text_position->AtStartOfLine());
1545 EXPECT_FALSE(text_position->AtEndOfLine());
1546
1547 text_position = AXNodePosition::CreateTextPosition(
1548 GetTreeID(), inline_box_data_4.id, 1 /* text_offset */,
1550 ASSERT_NE(nullptr, text_position);
1551 ASSERT_TRUE(text_position->IsTextPosition());
1552 EXPECT_FALSE(text_position->AtStartOfLine());
1553 EXPECT_TRUE(text_position->AtEndOfLine());
1554}

◆ TEST_F() [204/325]

ui::TEST_F ( AXPositionTest  ,
AtStartOfAnchorWithNullPosition   
)

Definition at line 1110 of file ax_node_position_unittest.cc.

1110 {
1111 TestPositionType null_position = AXNodePosition::CreateNullPosition();
1112 ASSERT_NE(nullptr, null_position);
1113 EXPECT_FALSE(null_position->AtStartOfAnchor());
1114}

◆ TEST_F() [205/325]

ui::TEST_F ( AXPositionTest  ,
AtStartOfAnchorWithTextPosition   
)

Definition at line 1145 of file ax_node_position_unittest.cc.

1145 {
1147 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
1149 ASSERT_NE(nullptr, text_position);
1150 ASSERT_TRUE(text_position->IsTextPosition());
1151 EXPECT_TRUE(text_position->AtStartOfAnchor());
1152
1153 text_position = AXNodePosition::CreateTextPosition(
1154 GetTreeID(), inline_box1_.id, 1 /* text_offset */,
1156 ASSERT_NE(nullptr, text_position);
1157 ASSERT_TRUE(text_position->IsTextPosition());
1158 EXPECT_FALSE(text_position->AtStartOfAnchor());
1159
1160 text_position = AXNodePosition::CreateTextPosition(
1161 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
1163 ASSERT_NE(nullptr, text_position);
1164 ASSERT_TRUE(text_position->IsTextPosition());
1165 EXPECT_FALSE(text_position->AtStartOfAnchor());
1166}

◆ TEST_F() [206/325]

ui::TEST_F ( AXPositionTest  ,
AtStartOfAnchorWithTreePosition   
)

Definition at line 1116 of file ax_node_position_unittest.cc.

1116 {
1117 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
1118 GetTreeID(), root_.id, 0 /* child_index */);
1119 ASSERT_NE(nullptr, tree_position);
1120 EXPECT_TRUE(tree_position->AtStartOfAnchor());
1121
1122 tree_position = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
1123 1 /* child_index */);
1124 ASSERT_NE(nullptr, tree_position);
1125 EXPECT_FALSE(tree_position->AtStartOfAnchor());
1126
1127 tree_position = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
1128 3 /* child_index */);
1129 ASSERT_NE(nullptr, tree_position);
1130 EXPECT_FALSE(tree_position->AtStartOfAnchor());
1131
1132 // A "before text" position.
1133 tree_position = AXNodePosition::CreateTreePosition(
1134 GetTreeID(), inline_box1_.id, AXNodePosition::BEFORE_TEXT);
1135 ASSERT_NE(nullptr, tree_position);
1136 EXPECT_TRUE(tree_position->AtStartOfAnchor());
1137
1138 // An "after text" position.
1139 tree_position = AXNodePosition::CreateTreePosition(
1140 GetTreeID(), inline_box1_.id, 0 /* child_index */);
1141 ASSERT_NE(nullptr, tree_position);
1142 EXPECT_FALSE(tree_position->AtStartOfAnchor());
1143}

◆ TEST_F() [207/325]

ui::TEST_F ( AXPositionTest  ,
AtStartOfBlankLine   
)

Definition at line 1365 of file ax_node_position_unittest.cc.

1365 {
1366 // Modify the test tree so that the line break will appear on a line of its
1367 // own, i.e. as creating a blank line.
1368 inline_box1_.RemoveIntAttribute(ax::mojom::IntAttribute::kNextOnLineId);
1369 line_break_.RemoveIntAttribute(ax::mojom::IntAttribute::kPreviousOnLineId);
1371 update.nodes = {inline_box1_, line_break_};
1372 ASSERT_TRUE(GetTree()->Unserialize(update));
1373
1374 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
1375 GetTreeID(), text_field_.id, 1 /* child_index */);
1376 ASSERT_NE(nullptr, tree_position);
1377 ASSERT_TRUE(tree_position->IsTreePosition());
1378 EXPECT_TRUE(tree_position->AtStartOfLine());
1379
1381 GetTreeID(), line_break_.id, 0 /* text_offset */,
1383 ASSERT_NE(nullptr, text_position);
1384 ASSERT_TRUE(text_position->IsTextPosition());
1385 EXPECT_TRUE(text_position->AtStartOfLine());
1386
1387 // A text position after a blank line should be equivalent to a "before text"
1388 // position at the line that comes after it.
1389 text_position = AXNodePosition::CreateTextPosition(
1390 GetTreeID(), line_break_.id, 1 /* text_offset */,
1392 ASSERT_NE(nullptr, text_position);
1393 ASSERT_TRUE(text_position->IsTextPosition());
1394 EXPECT_TRUE(text_position->AtStartOfLine());
1395}

◆ TEST_F() [208/325]

ui::TEST_F ( AXPositionTest  ,
AtStartOfLineStaticTextExtraPrecedingSpace   
)

Definition at line 1264 of file ax_node_position_unittest.cc.

1264 {
1265 // Consider the following web content:
1266 // <style>
1267 // .required-label::after {
1268 // content: " *";
1269 // }
1270 // </style>
1271 // <label class="required-label">Required </label>
1272 //
1273 // Which has the following AXTree, where the static text (#3)
1274 // contains an extra preceding space compared to its inline text (#4).
1275 // ++1 kRootWebArea
1276 // ++++2 kLabelText
1277 // ++++++3 kStaticText name=" *"
1278 // ++++++++4 kInlineTextBox name="*"
1279 // This test ensures that this difference between static text and its inline
1280 // text box does not cause a hang when AtStartOfLine is called on static text
1281 // with text position " <*>".
1282
1284 root.id = 1;
1286 // "kIsLineBreakingObject" is not strictly necessary but is added for
1287 // completeness.
1289 AXNodeData label_text;
1290 label_text.id = 2;
1291 label_text.role = ax::mojom::Role::kLabelText;
1292
1293 AXNodeData static_text1;
1294 static_text1.id = 3;
1295 static_text1.role = ax::mojom::Role::kStaticText;
1296 static_text1.SetName(" *");
1297
1298 AXNodeData inline_text1;
1299 inline_text1.id = 4;
1301 inline_text1.SetName("*");
1302
1303 static_text1.child_ids = {inline_text1.id};
1304 root.child_ids = {static_text1.id};
1305
1306 SetTree(CreateAXTree({root, static_text1, inline_text1}));
1307
1308 // Calling AtStartOfLine on |static_text1| with position " <*>",
1309 // text_offset_=1, should not get into an infinite loop; it should be
1310 // guaranteed to terminate.
1312 GetTreeID(), static_text1.id, 1 /* child_index */,
1314 ASSERT_FALSE(text_position->AtStartOfLine());
1315}

◆ TEST_F() [209/325]

ui::TEST_F ( AXPositionTest  ,
AtStartOfLineWithTextPosition   
)

Definition at line 1214 of file ax_node_position_unittest.cc.

1214 {
1215 // An upstream affinity should not affect the outcome since there is no soft
1216 // line break.
1218 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
1220 ASSERT_NE(nullptr, text_position);
1221 ASSERT_TRUE(text_position->IsTextPosition());
1222 EXPECT_TRUE(text_position->AtStartOfLine());
1223
1224 text_position = AXNodePosition::CreateTextPosition(
1225 GetTreeID(), inline_box1_.id, 1 /* text_offset */,
1227 ASSERT_NE(nullptr, text_position);
1228 ASSERT_TRUE(text_position->IsTextPosition());
1229 EXPECT_FALSE(text_position->AtStartOfLine());
1230
1231 text_position = AXNodePosition::CreateTextPosition(
1232 GetTreeID(), line_break_.id, 0 /* text_offset */,
1234 ASSERT_NE(nullptr, text_position);
1235 ASSERT_TRUE(text_position->IsTextPosition());
1236 EXPECT_FALSE(text_position->AtStartOfLine());
1237
1238 // An "after text" position anchored at the line break should be equivalent to
1239 // a "before text" position at the start of the next line.
1240 text_position = AXNodePosition::CreateTextPosition(
1241 GetTreeID(), line_break_.id, 1 /* text_offset */,
1243 ASSERT_NE(nullptr, text_position);
1244 ASSERT_TRUE(text_position->IsTextPosition());
1245 EXPECT_TRUE(text_position->AtStartOfLine());
1246
1247 // An upstream affinity should not affect the outcome since there is no soft
1248 // line break.
1249 text_position = AXNodePosition::CreateTextPosition(
1250 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
1252 ASSERT_NE(nullptr, text_position);
1253 ASSERT_TRUE(text_position->IsTextPosition());
1254 EXPECT_TRUE(text_position->AtStartOfLine());
1255
1256 text_position = AXNodePosition::CreateTextPosition(
1257 GetTreeID(), inline_box2_.id, 1 /* text_offset */,
1259 ASSERT_NE(nullptr, text_position);
1260 ASSERT_TRUE(text_position->IsTextPosition());
1261 EXPECT_FALSE(text_position->AtStartOfLine());
1262}

◆ TEST_F() [210/325]

ui::TEST_F ( AXPositionTest  ,
AtStartOfParagraphWithTextPosition   
)

Definition at line 1719 of file ax_node_position_unittest.cc.

1719 {
1720 // An upstream affinity should not affect the outcome since there is no soft
1721 // line break.
1723 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
1725 ASSERT_NE(nullptr, text_position);
1726 ASSERT_TRUE(text_position->IsTextPosition());
1727 EXPECT_TRUE(text_position->AtStartOfParagraph());
1728
1729 text_position = AXNodePosition::CreateTextPosition(
1730 GetTreeID(), inline_box1_.id, 1 /* text_offset */,
1732 ASSERT_NE(nullptr, text_position);
1733 ASSERT_TRUE(text_position->IsTextPosition());
1734 EXPECT_FALSE(text_position->AtStartOfParagraph());
1735
1736 text_position = AXNodePosition::CreateTextPosition(
1737 GetTreeID(), line_break_.id, 0 /* text_offset */,
1739 ASSERT_NE(nullptr, text_position);
1740 ASSERT_TRUE(text_position->IsTextPosition());
1741 EXPECT_FALSE(text_position->AtStartOfParagraph());
1742
1743 // An "after text" position anchored at the line break should not be the same
1744 // as a text position at the start of the next paragraph because in practice
1745 // they should have resulted from two different ancestor positions. The former
1746 // should have been an upstream position, whilst the latter a downstream one.
1747 text_position = AXNodePosition::CreateTextPosition(
1748 GetTreeID(), line_break_.id, 1 /* text_offset */,
1750 ASSERT_NE(nullptr, text_position);
1751 ASSERT_TRUE(text_position->IsTextPosition());
1752 EXPECT_FALSE(text_position->AtStartOfParagraph());
1753
1754 // An upstream affinity should not affect the outcome since there is no soft
1755 // line break.
1756 text_position = AXNodePosition::CreateTextPosition(
1757 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
1759 ASSERT_NE(nullptr, text_position);
1760 ASSERT_TRUE(text_position->IsTextPosition());
1761 EXPECT_TRUE(text_position->AtStartOfParagraph());
1762
1763 text_position = AXNodePosition::CreateTextPosition(
1764 GetTreeID(), inline_box2_.id, 1 /* text_offset */,
1766 ASSERT_NE(nullptr, text_position);
1767 ASSERT_TRUE(text_position->IsTextPosition());
1768 EXPECT_FALSE(text_position->AtStartOfParagraph());
1769}

◆ TEST_F() [211/325]

ui::TEST_F ( AXPositionTest  ,
AtStartOrEndOfParagraphOnAListMarker   
)

Definition at line 2028 of file ax_node_position_unittest.cc.

2028 {
2029 // "AtStartOfParagraph" should return true before a list marker, either a
2030 // Legacy Layout or an NG Layout one. It should return false on the next
2031 // sibling of the list marker, i.e., before the list item's actual text
2032 // contents.
2033 //
2034 // There are two list markers in the following test tree. The first one is a
2035 // Legacy Layout one and the second an NG Layout one.
2036 // ++1 kRootWebArea
2037 // ++++2 kStaticText "Before list."
2038 // ++++++3 kInlineTextBox "Before list."
2039 // ++++4 kList
2040 // ++++++5 kListItem
2041 // ++++++++6 kListMarker
2042 // ++++++++++7 kStaticText "1. "
2043 // ++++++++++++8 kInlineTextBox "1. "
2044 // ++++++++9 kStaticText "First item."
2045 // ++++++++++10 kInlineTextBox "First item."
2046 // ++++++11 kListItem
2047 // ++++++++12 kListMarker "2. "
2048 // ++++++++13 kStaticText "Second item."
2049 // ++++++++++14 kInlineTextBox "Second item."
2050 // ++15 kStaticText "After list."
2051 // ++++16 kInlineTextBox "After list."
2052
2054 AXNodeData list;
2055 AXNodeData list_item1;
2056 AXNodeData list_item2;
2057 AXNodeData list_marker_legacy;
2058 AXNodeData list_marker_ng;
2059 AXNodeData static_text1;
2060 AXNodeData static_text2;
2061 AXNodeData static_text3;
2062 AXNodeData static_text4;
2063 AXNodeData static_text5;
2064 AXNodeData inline_box1;
2065 AXNodeData inline_box2;
2066 AXNodeData inline_box3;
2067 AXNodeData inline_box4;
2068 AXNodeData inline_box5;
2069
2070 root.id = 1;
2071 static_text1.id = 2;
2072 inline_box1.id = 3;
2073 list.id = 4;
2074 list_item1.id = 5;
2075 list_marker_legacy.id = 6;
2076 static_text2.id = 7;
2077 inline_box2.id = 8;
2078 static_text3.id = 9;
2079 inline_box3.id = 10;
2080 list_item2.id = 11;
2081 list_marker_ng.id = 12;
2082 static_text4.id = 13;
2083 inline_box4.id = 14;
2084 static_text5.id = 15;
2085 inline_box5.id = 16;
2086
2088 root.child_ids = {static_text1.id, list.id, static_text5.id};
2090
2091 static_text1.role = ax::mojom::Role::kStaticText;
2092 static_text1.child_ids = {inline_box1.id};
2093 static_text1.SetName("Before list.");
2094
2096 inline_box1.SetName("Before list.");
2097
2099 list.child_ids = {list_item1.id, list_item2.id};
2100
2101 list_item1.role = ax::mojom::Role::kListItem;
2102 list_item1.child_ids = {list_marker_legacy.id, static_text3.id};
2104 true);
2105
2106 list_marker_legacy.role = ax::mojom::Role::kListMarker;
2107 list_marker_legacy.child_ids = {static_text2.id};
2108
2109 static_text2.role = ax::mojom::Role::kStaticText;
2110 static_text2.child_ids = {inline_box2.id};
2111 static_text2.SetName("1. ");
2112
2114 inline_box2.SetName("1. ");
2116 inline_box3.id);
2117
2118 static_text3.role = ax::mojom::Role::kStaticText;
2119 static_text3.child_ids = {inline_box3.id};
2120 static_text3.SetName("First item.");
2121
2123 inline_box3.SetName("First item.");
2125 inline_box2.id);
2126
2127 list_item2.role = ax::mojom::Role::kListItem;
2128 list_item2.child_ids = {list_marker_ng.id, static_text4.id};
2130 true);
2131
2132 list_marker_ng.role = ax::mojom::Role::kListMarker;
2133 list_marker_ng.SetName("2. ");
2135 inline_box4.id);
2136
2137 static_text4.role = ax::mojom::Role::kStaticText;
2138 static_text4.child_ids = {inline_box4.id};
2139 static_text4.SetName("Second item.");
2140
2142 inline_box4.SetName("Second item.");
2144 list_marker_ng.id);
2145
2146 static_text5.role = ax::mojom::Role::kStaticText;
2147 static_text5.child_ids = {inline_box5.id};
2148 static_text5.SetName("After list.");
2149
2151 inline_box5.SetName("After list.");
2152
2153 SetTree(CreateAXTree({root, static_text1, inline_box1, list, list_item1,
2154 list_marker_legacy, static_text2, inline_box2,
2155 static_text3, inline_box3, list_item2, list_marker_ng,
2156 static_text4, inline_box4, static_text5, inline_box5}));
2157
2158 // A text position after the text "Before list.". It should not be equivalent
2159 // to a position that is before the list itself, or before the first list
2160 // bullet / item.
2162 GetTreeID(), static_text1.id, 12 /* text_offset */,
2164 ASSERT_NE(nullptr, text_position);
2165 EXPECT_FALSE(text_position->AtStartOfParagraph());
2166 EXPECT_TRUE(text_position->AtEndOfParagraph());
2167
2168 // A text position after the text "Before list.". It should not be equivalent
2169 // to a position that is before the list itself, or before the first list
2170 // bullet / item.
2171 text_position = AXNodePosition::CreateTextPosition(
2172 GetTreeID(), inline_box1.id, 12 /* text_offset */,
2174 ASSERT_NE(nullptr, text_position);
2175 EXPECT_FALSE(text_position->AtStartOfParagraph());
2176 EXPECT_TRUE(text_position->AtEndOfParagraph());
2177
2178 // A text position before the list.
2179 text_position = AXNodePosition::CreateTextPosition(
2180 GetTreeID(), list.id, 0 /* text_offset */,
2182 ASSERT_NE(nullptr, text_position);
2183 EXPECT_TRUE(text_position->AtStartOfParagraph());
2184 EXPECT_FALSE(text_position->AtEndOfParagraph());
2185
2186 // A downstream text position after the list. It should resolve to a leaf
2187 // position before the paragraph that comes after the list, so it should be
2188 // "AtStartOfParagraph".
2189 text_position = AXNodePosition::CreateTextPosition(
2190 GetTreeID(), list.id, 14 /* text_offset */,
2192 ASSERT_NE(nullptr, text_position);
2193 EXPECT_TRUE(text_position->AtStartOfParagraph());
2194 EXPECT_FALSE(text_position->AtEndOfParagraph());
2195
2196 // An upstream text position after the list. It should be "AtEndOfParagraph".
2197 text_position = AXNodePosition::CreateTextPosition(
2198 GetTreeID(), list.id, 14 /* text_offset */,
2200 ASSERT_NE(nullptr, text_position);
2201 EXPECT_FALSE(text_position->AtStartOfParagraph());
2202 EXPECT_TRUE(text_position->AtEndOfParagraph());
2203
2204 // A text position before the first list bullet (the Legacy Layout one).
2205 text_position = AXNodePosition::CreateTextPosition(
2206 GetTreeID(), list_marker_legacy.id, 0 /* text_offset */,
2208 ASSERT_NE(nullptr, text_position);
2209 EXPECT_TRUE(text_position->AtStartOfParagraph());
2210 EXPECT_FALSE(text_position->AtEndOfParagraph());
2211
2212 text_position = AXNodePosition::CreateTextPosition(
2213 GetTreeID(), list_marker_legacy.id, 1 /* text_offset */,
2215 ASSERT_NE(nullptr, text_position);
2216 EXPECT_FALSE(text_position->AtStartOfParagraph());
2217 EXPECT_FALSE(text_position->AtEndOfParagraph());
2218
2219 // A text position before the first list bullet (the Legacy Layout one).
2220 text_position = AXNodePosition::CreateTextPosition(
2221 GetTreeID(), static_text2.id, 0 /* text_offset */,
2223 ASSERT_NE(nullptr, text_position);
2224 EXPECT_TRUE(text_position->AtStartOfParagraph());
2225 EXPECT_FALSE(text_position->AtEndOfParagraph());
2226
2227 text_position = AXNodePosition::CreateTextPosition(
2228 GetTreeID(), static_text2.id, 2 /* text_offset */,
2230 ASSERT_NE(nullptr, text_position);
2231 EXPECT_FALSE(text_position->AtStartOfParagraph());
2232 EXPECT_FALSE(text_position->AtEndOfParagraph());
2233
2234 // A text position before the first list bullet (the Legacy Layout one).
2235 text_position = AXNodePosition::CreateTextPosition(
2236 GetTreeID(), inline_box2.id, 0 /* text_offset */,
2238 ASSERT_NE(nullptr, text_position);
2239 EXPECT_TRUE(text_position->AtStartOfParagraph());
2240 EXPECT_FALSE(text_position->AtEndOfParagraph());
2241
2242 text_position = AXNodePosition::CreateTextPosition(
2243 GetTreeID(), inline_box2.id, 3 /* text_offset */,
2245 ASSERT_NE(nullptr, text_position);
2246 EXPECT_FALSE(text_position->AtStartOfParagraph());
2247 EXPECT_FALSE(text_position->AtEndOfParagraph());
2248
2249 // A text position before the second list bullet (the NG Layout one).
2250 text_position = AXNodePosition::CreateTextPosition(
2251 GetTreeID(), list_marker_ng.id, 0 /* text_offset */,
2253 ASSERT_NE(nullptr, text_position);
2254 EXPECT_TRUE(text_position->AtStartOfParagraph());
2255 EXPECT_FALSE(text_position->AtEndOfParagraph());
2256
2257 text_position = AXNodePosition::CreateTextPosition(
2258 GetTreeID(), list_marker_ng.id, 3 /* text_offset */,
2260 ASSERT_NE(nullptr, text_position);
2261 EXPECT_FALSE(text_position->AtStartOfParagraph());
2262 EXPECT_FALSE(text_position->AtEndOfParagraph());
2263
2264 // A text position before the text contents of the first list item - not the
2265 // bullet.
2266 text_position = AXNodePosition::CreateTextPosition(
2267 GetTreeID(), static_text3.id, 0 /* text_offset */,
2269 ASSERT_NE(nullptr, text_position);
2270 EXPECT_FALSE(text_position->AtStartOfParagraph());
2271 EXPECT_FALSE(text_position->AtEndOfParagraph());
2272
2273 // A text position before the text contents of the first list item - not the
2274 // bullet.
2275 text_position = AXNodePosition::CreateTextPosition(
2276 GetTreeID(), inline_box3.id, 0 /* text_offset */,
2278 ASSERT_NE(nullptr, text_position);
2279 EXPECT_FALSE(text_position->AtStartOfParagraph());
2280 EXPECT_FALSE(text_position->AtEndOfParagraph());
2281
2282 // A text position after the text contents of the first list item.
2283 text_position = AXNodePosition::CreateTextPosition(
2284 GetTreeID(), static_text3.id, 11 /* text_offset */,
2286 ASSERT_NE(nullptr, text_position);
2287 EXPECT_FALSE(text_position->AtStartOfParagraph());
2288 EXPECT_TRUE(text_position->AtEndOfParagraph());
2289
2290 // A text position after the text contents of the first list item.
2291 text_position = AXNodePosition::CreateTextPosition(
2292 GetTreeID(), inline_box3.id, 11 /* text_offset */,
2294 ASSERT_NE(nullptr, text_position);
2295 EXPECT_FALSE(text_position->AtStartOfParagraph());
2296 EXPECT_TRUE(text_position->AtEndOfParagraph());
2297
2298 // A text position before the text contents of the second list item - not the
2299 // bullet.
2300 text_position = AXNodePosition::CreateTextPosition(
2301 GetTreeID(), static_text4.id, 0 /* text_offset */,
2303 ASSERT_NE(nullptr, text_position);
2304 EXPECT_FALSE(text_position->AtStartOfParagraph());
2305 EXPECT_FALSE(text_position->AtEndOfParagraph());
2306
2307 // A text position before the text contents of the second list item - not the
2308 // bullet.
2309 text_position = AXNodePosition::CreateTextPosition(
2310 GetTreeID(), inline_box4.id, 0 /* text_offset */,
2312 ASSERT_NE(nullptr, text_position);
2313 EXPECT_FALSE(text_position->AtStartOfParagraph());
2314 EXPECT_FALSE(text_position->AtEndOfParagraph());
2315
2316 // A text position after the text contents of the second list item.
2317 text_position = AXNodePosition::CreateTextPosition(
2318 GetTreeID(), static_text4.id, 12 /* text_offset */,
2320 ASSERT_NE(nullptr, text_position);
2321 EXPECT_FALSE(text_position->AtStartOfParagraph());
2322 EXPECT_TRUE(text_position->AtEndOfParagraph());
2323
2324 // A text position after the text contents of the second list item.
2325 text_position = AXNodePosition::CreateTextPosition(
2326 GetTreeID(), inline_box4.id, 12 /* text_offset */,
2328 ASSERT_NE(nullptr, text_position);
2329 EXPECT_FALSE(text_position->AtStartOfParagraph());
2330 EXPECT_TRUE(text_position->AtEndOfParagraph());
2331
2332 // A text position before the text "After list.".
2333 text_position = AXNodePosition::CreateTextPosition(
2334 GetTreeID(), inline_box5.id, 0 /* text_offset */,
2336 ASSERT_NE(nullptr, text_position);
2337 EXPECT_TRUE(text_position->AtStartOfParagraph());
2338 EXPECT_FALSE(text_position->AtEndOfParagraph());
2339}

◆ TEST_F() [212/325]

ui::TEST_F ( AXPositionTest  ,
AtStartOrEndOfParagraphWithEmbeddedObjectCharacter   
)

Definition at line 2705 of file ax_node_position_unittest.cc.

2705 {
2706 g_ax_embedded_object_behavior = AXEmbeddedObjectBehavior::kExposeCharacter;
2707
2708 // This test ensures that "At{Start|End}OfParagraph" work correctly when there
2709 // are embedded objects present near a paragraph boundary.
2710 //
2711 // Nodes represented by an embedded object character, such as a plain text
2712 // field or a check box, should create an implicit paragraph boundary for
2713 // assistive software.
2714 // ++1 kRootWebArea isLineBreakingObject
2715 // ++++2 kLink
2716 // ++++++3 kStaticText "hello"
2717 // ++++++++4 kInlineTextBox "hello"
2718 // ++++++5 kImage
2719 // ++++++6 kStaticText "world"
2720 // ++++++++7 kInlineTextBox "world"
2721
2722 AXNodeData root_1;
2723 AXNodeData link_2;
2724 AXNodeData static_text_3;
2725 AXNodeData inline_box_4;
2726 AXNodeData image_5;
2727 AXNodeData static_text_6;
2728 AXNodeData inline_box_7;
2729
2730 root_1.id = 1;
2731 link_2.id = 2;
2732 static_text_3.id = 3;
2733 inline_box_4.id = 4;
2734 image_5.id = 5;
2735 static_text_6.id = 6;
2736 inline_box_7.id = 7;
2737
2739 root_1.child_ids = {link_2.id};
2741 true);
2742
2744 link_2.child_ids = {static_text_3.id, image_5.id, static_text_6.id};
2745
2746 static_text_3.role = ax::mojom::Role::kStaticText;
2747 static_text_3.child_ids = {inline_box_4.id};
2748 static_text_3.SetName("Hello");
2749
2751 inline_box_4.SetName("Hello");
2752
2753 image_5.role = ax::mojom::Role::kImage;
2754 // The image's inner text should be an embedded object character.
2755
2756 static_text_6.role = ax::mojom::Role::kStaticText;
2757 static_text_6.child_ids = {inline_box_7.id};
2758 static_text_6.SetName("world");
2759
2761 inline_box_7.SetName("world");
2762
2763 SetTree(CreateAXTree({root_1, link_2, static_text_3, inline_box_4, image_5,
2764 static_text_6, inline_box_7}));
2765
2766 // Before "hello".
2768 GetTreeID(), inline_box_4.id, 0 /* text_offset */,
2770 EXPECT_FALSE(text_position->AtEndOfParagraph());
2771 EXPECT_TRUE(text_position->AtStartOfParagraph());
2772
2773 // After "hello".
2774 //
2775 // Note that even though this position and a position before the image's
2776 // embedded object character are conceptually equivalent, in practice they
2777 // should result from two different ancestor positions. The former should have
2778 // been an upstream position, whilst the latter a downstream one.
2779 text_position = AXNodePosition::CreateTextPosition(
2780 GetTreeID(), inline_box_4.id, 5 /* text_offset */,
2782 EXPECT_TRUE(text_position->AtEndOfParagraph());
2783 EXPECT_FALSE(text_position->AtStartOfParagraph());
2784
2785 // Before the image's embedded object character.
2786 text_position = AXNodePosition::CreateTextPosition(
2787 GetTreeID(), image_5.id, 0 /* text_offset */,
2789 EXPECT_FALSE(text_position->AtEndOfParagraph());
2790 EXPECT_TRUE(text_position->AtStartOfParagraph());
2791
2792 // After the image's embedded object character.
2793 text_position = AXNodePosition::CreateTextPosition(
2794 GetTreeID(), image_5.id, 1 /* text_offset */,
2796 EXPECT_TRUE(text_position->AtEndOfParagraph());
2797 EXPECT_FALSE(text_position->AtStartOfParagraph());
2798
2799 // Before "world".
2800 text_position = AXNodePosition::CreateTextPosition(
2801 GetTreeID(), inline_box_7.id, 0 /* text_offset */,
2803 EXPECT_FALSE(text_position->AtEndOfParagraph());
2804 EXPECT_TRUE(text_position->AtStartOfParagraph());
2805
2806 // After "world".
2807 text_position = AXNodePosition::CreateTextPosition(
2808 GetTreeID(), inline_box_7.id, 5 /* text_offset */,
2810 EXPECT_TRUE(text_position->AtEndOfParagraph());
2811 EXPECT_FALSE(text_position->AtStartOfParagraph());
2812}

◆ TEST_F() [213/325]

ui::TEST_F ( AXPositionTest  ,
AtStartOrEndOfParagraphWithIgnoredNodes   
)

Definition at line 2522 of file ax_node_position_unittest.cc.

2522 {
2523 // This test ensures that "At{Start|End}OfParagraph" work correctly when there
2524 // are ignored nodes present near a paragraph boundary.
2525 //
2526 // An ignored node that is between a given position and a paragraph boundary
2527 // should not be taken into consideration. The position should be interpreted
2528 // as being on the boundary.
2529 // ++1 kRootWebArea isLineBreakingObject
2530 // ++++2 kGenericContainer ignored isLineBreakingObject
2531 // ++++++3 kStaticText ignored "ignored text"
2532 // ++++++++4 kInlineTextBox ignored "ignored text"
2533 // ++++5 kGenericContainer isLineBreakingObject
2534 // ++++++6 kStaticText "some text"
2535 // ++++++++7 kInlineTextBox "some"
2536 // ++++++++8 kInlineTextBox " "
2537 // ++++++++9 kInlineTextBox "text"
2538 // ++++10 kGenericContainer ignored isLineBreakingObject
2539 // ++++++11 kStaticText ignored "ignored text"
2540 // ++++++++12 kInlineTextBox ignored "ignored text"
2541
2542 AXNodeData root_data;
2543 root_data.id = 1;
2546 true);
2547
2548 AXNodeData container_data_a;
2549 container_data_a.id = 2;
2550 container_data_a.role = ax::mojom::Role::kGenericContainer;
2551 container_data_a.AddState(ax::mojom::State::kIgnored);
2552 container_data_a.AddBoolAttribute(
2554
2555 AXNodeData static_text_data_a;
2556 static_text_data_a.id = 3;
2557 static_text_data_a.role = ax::mojom::Role::kStaticText;
2558 static_text_data_a.SetName("ignored text");
2559 static_text_data_a.AddState(ax::mojom::State::kIgnored);
2560
2561 AXNodeData inline_text_data_a;
2562 inline_text_data_a.id = 4;
2563 inline_text_data_a.role = ax::mojom::Role::kInlineTextBox;
2564 inline_text_data_a.SetName("ignored text");
2565 inline_text_data_a.AddState(ax::mojom::State::kIgnored);
2566
2567 AXNodeData container_data_b;
2568 container_data_b.id = 5;
2569 container_data_b.role = ax::mojom::Role::kGenericContainer;
2570 container_data_b.AddBoolAttribute(
2572
2573 AXNodeData static_text_data_b;
2574 static_text_data_b.id = 6;
2575 static_text_data_b.role = ax::mojom::Role::kStaticText;
2576 static_text_data_b.SetName("some text");
2577
2578 AXNodeData inline_text_data_b_1;
2579 inline_text_data_b_1.id = 7;
2580 inline_text_data_b_1.role = ax::mojom::Role::kInlineTextBox;
2581 inline_text_data_b_1.SetName("some");
2582
2583 AXNodeData inline_text_data_b_2;
2584 inline_text_data_b_2.id = 8;
2585 inline_text_data_b_2.role = ax::mojom::Role::kInlineTextBox;
2586 inline_text_data_b_2.SetName(" ");
2587
2588 AXNodeData inline_text_data_b_3;
2589 inline_text_data_b_3.id = 9;
2590 inline_text_data_b_3.role = ax::mojom::Role::kInlineTextBox;
2591 inline_text_data_b_3.SetName("text");
2592
2593 AXNodeData container_data_c;
2594 container_data_c.id = 10;
2595 container_data_c.role = ax::mojom::Role::kGenericContainer;
2596 container_data_c.AddState(ax::mojom::State::kIgnored);
2597 container_data_c.AddBoolAttribute(
2599
2600 AXNodeData static_text_data_c;
2601 static_text_data_c.id = 11;
2602 static_text_data_c.role = ax::mojom::Role::kStaticText;
2603 static_text_data_c.SetName("ignored text");
2604 static_text_data_c.AddState(ax::mojom::State::kIgnored);
2605
2606 AXNodeData inline_text_data_c;
2607 inline_text_data_c.id = 12;
2608 inline_text_data_c.role = ax::mojom::Role::kInlineTextBox;
2609 inline_text_data_c.SetName("ignored text");
2610 inline_text_data_c.AddState(ax::mojom::State::kIgnored);
2611
2612 root_data.child_ids = {container_data_a.id, container_data_b.id,
2613 container_data_c.id};
2614 container_data_a.child_ids = {static_text_data_a.id};
2615 static_text_data_a.child_ids = {inline_text_data_a.id};
2616 container_data_b.child_ids = {static_text_data_b.id};
2617 static_text_data_b.child_ids = {inline_text_data_b_1.id,
2618 inline_text_data_b_2.id,
2619 inline_text_data_b_3.id};
2620 container_data_c.child_ids = {static_text_data_c.id};
2621 static_text_data_c.child_ids = {inline_text_data_c.id};
2622
2623 SetTree(CreateAXTree(
2624 {root_data, container_data_a, container_data_b, container_data_c,
2625 static_text_data_a, static_text_data_b, static_text_data_c,
2626 inline_text_data_a, inline_text_data_b_1, inline_text_data_b_2,
2627 inline_text_data_b_3, inline_text_data_c}));
2628
2629 // Before "ignored text".
2631 GetTreeID(), inline_text_data_a.id, 0 /* text_offset */,
2633 EXPECT_FALSE(text_position1->AtEndOfParagraph());
2634 EXPECT_FALSE(text_position1->AtStartOfParagraph());
2635
2636 // After "ignored text".
2637 //
2638 // Since the position is an "after text" position, it is similar to pressing
2639 // the End key, (or Cmd-Right on Mac), while the caret is on "ignored text",
2640 // so it should not be "AtStartOfParagraph". In practice, this situation
2641 // should not arise in accessibility, because the node is ignored.
2643 GetTreeID(), inline_text_data_a.id, 12 /* text_offset */,
2645 EXPECT_FALSE(text_position2->AtEndOfParagraph());
2646 EXPECT_FALSE(text_position2->AtStartOfParagraph());
2647
2648 // Before "some".
2650 GetTreeID(), inline_text_data_b_1.id, 0 /* text_offset */,
2652 EXPECT_FALSE(text_position3->AtEndOfParagraph());
2653 EXPECT_TRUE(text_position3->AtStartOfParagraph());
2654
2655 // After "some".
2657 GetTreeID(), inline_text_data_b_1.id, 4 /* text_offset */,
2659 EXPECT_FALSE(text_position4->AtEndOfParagraph());
2660 EXPECT_FALSE(text_position4->AtStartOfParagraph());
2661
2662 // Before " ".
2664 GetTreeID(), inline_text_data_b_2.id, 0 /* text_offset */,
2666 EXPECT_FALSE(text_position5->AtEndOfParagraph());
2667 EXPECT_FALSE(text_position5->AtStartOfParagraph());
2668
2669 // After " ".
2671 GetTreeID(), inline_text_data_b_2.id, 1 /* text_offset */,
2673 EXPECT_FALSE(text_position6->AtEndOfParagraph());
2674 EXPECT_FALSE(text_position6->AtStartOfParagraph());
2675
2676 // Before "text".
2678 GetTreeID(), inline_text_data_b_3.id, 0 /* text_offset */,
2680 EXPECT_FALSE(text_position7->AtEndOfParagraph());
2681 EXPECT_FALSE(text_position7->AtStartOfParagraph());
2682
2683 // After "text".
2685 GetTreeID(), inline_text_data_b_3.id, 4 /* text_offset */,
2687 EXPECT_TRUE(text_position8->AtEndOfParagraph());
2688 EXPECT_FALSE(text_position8->AtStartOfParagraph());
2689
2690 // Before "ignored text" - the second version.
2692 GetTreeID(), inline_text_data_c.id, 0 /* text_offset */,
2694 EXPECT_FALSE(text_position9->AtEndOfParagraph());
2695 EXPECT_FALSE(text_position9->AtStartOfParagraph());
2696
2697 // After "ignored text" - the second version.
2699 GetTreeID(), inline_text_data_c.id, 12 /* text_offset */,
2701 EXPECT_FALSE(text_position10->AtEndOfParagraph());
2702 EXPECT_FALSE(text_position10->AtStartOfParagraph());
2703}

◆ TEST_F() [214/325]

ui::TEST_F ( AXPositionTest  ,
AtStartOrEndOfParagraphWithLeadingAndTrailingDocumentWhitespace   
)

Definition at line 2341 of file ax_node_position_unittest.cc.

2342 {
2343 // This test ensures that "At{Start|End}OfParagraph" work correctly when a
2344 // text position is on a preserved newline character.
2345 //
2346 // Newline characters are used to separate paragraphs. If there is a series of
2347 // newline characters, a paragraph should start after the last newline
2348 // character.
2349 // ++1 kRootWebArea isLineBreakingObject
2350 // ++++2 kGenericContainer isLineBreakingObject
2351 // ++++++3 kStaticText "\n"
2352 // ++++++++4 kInlineTextBox "\n" isLineBreakingObject
2353 // ++++5 kGenericContainer isLineBreakingObject
2354 // ++++++6 kStaticText "some text"
2355 // ++++++++7 kInlineTextBox "some"
2356 // ++++++++8 kInlineTextBox " "
2357 // ++++++++9 kInlineTextBox "text"
2358 // ++++10 kGenericContainer isLineBreakingObject
2359 // ++++++11 kStaticText "\n"
2360 // ++++++++12 kInlineTextBox "\n" isLineBreakingObject
2361
2362 AXNodeData root_data;
2363 root_data.id = 1;
2366 true);
2367
2368 AXNodeData container_data_a;
2369 container_data_a.id = 2;
2370 container_data_a.role = ax::mojom::Role::kGenericContainer;
2371 container_data_a.AddBoolAttribute(
2373
2374 AXNodeData static_text_data_a;
2375 static_text_data_a.id = 3;
2376 static_text_data_a.role = ax::mojom::Role::kStaticText;
2377 static_text_data_a.SetName("\n");
2378
2379 AXNodeData inline_text_data_a;
2380 inline_text_data_a.id = 4;
2381 inline_text_data_a.role = ax::mojom::Role::kInlineTextBox;
2382 inline_text_data_a.SetName("\n");
2383 inline_text_data_a.AddBoolAttribute(
2385
2386 AXNodeData container_data_b;
2387 container_data_b.id = 5;
2388 container_data_b.role = ax::mojom::Role::kGenericContainer;
2389 container_data_b.AddBoolAttribute(
2391
2392 AXNodeData static_text_data_b;
2393 static_text_data_b.id = 6;
2394 static_text_data_b.role = ax::mojom::Role::kStaticText;
2395 static_text_data_b.SetName("some text");
2396
2397 AXNodeData inline_text_data_b_1;
2398 inline_text_data_b_1.id = 7;
2399 inline_text_data_b_1.role = ax::mojom::Role::kInlineTextBox;
2400 inline_text_data_b_1.SetName("some");
2401
2402 AXNodeData inline_text_data_b_2;
2403 inline_text_data_b_2.id = 8;
2404 inline_text_data_b_2.role = ax::mojom::Role::kInlineTextBox;
2405 inline_text_data_b_2.SetName(" ");
2406
2407 AXNodeData inline_text_data_b_3;
2408 inline_text_data_b_3.id = 9;
2409 inline_text_data_b_3.role = ax::mojom::Role::kInlineTextBox;
2410 inline_text_data_b_3.SetName("text");
2411
2412 AXNodeData container_data_c;
2413 container_data_c.id = 10;
2414 container_data_c.role = ax::mojom::Role::kGenericContainer;
2415 container_data_c.AddBoolAttribute(
2417
2418 AXNodeData static_text_data_c;
2419 static_text_data_c.id = 11;
2420 static_text_data_c.role = ax::mojom::Role::kStaticText;
2421 static_text_data_c.SetName("\n");
2422
2423 AXNodeData inline_text_data_c;
2424 inline_text_data_c.id = 12;
2425 inline_text_data_c.role = ax::mojom::Role::kInlineTextBox;
2426 inline_text_data_c.SetName("\n");
2427 inline_text_data_c.AddBoolAttribute(
2429
2430 root_data.child_ids = {container_data_a.id, container_data_b.id,
2431 container_data_c.id};
2432 container_data_a.child_ids = {static_text_data_a.id};
2433 static_text_data_a.child_ids = {inline_text_data_a.id};
2434 container_data_b.child_ids = {static_text_data_b.id};
2435 static_text_data_b.child_ids = {inline_text_data_b_1.id,
2436 inline_text_data_b_2.id,
2437 inline_text_data_b_3.id};
2438 container_data_c.child_ids = {static_text_data_c.id};
2439 static_text_data_c.child_ids = {inline_text_data_c.id};
2440
2441 SetTree(CreateAXTree(
2442 {root_data, container_data_a, container_data_b, container_data_c,
2443 static_text_data_a, static_text_data_b, static_text_data_c,
2444 inline_text_data_a, inline_text_data_b_1, inline_text_data_b_2,
2445 inline_text_data_b_3, inline_text_data_c}));
2446
2447 // Before the first "\n".
2449 GetTreeID(), inline_text_data_a.id, 0 /* text_offset */,
2451 EXPECT_FALSE(text_position1->AtEndOfParagraph());
2452 EXPECT_TRUE(text_position1->AtStartOfParagraph());
2453
2454 // After the first "\n".
2455 //
2456 // Since the position is an "after text" position, it is similar to pressing
2457 // the End key, (or Cmd-Right on Mac), while the caret is on the line break,
2458 // so it should not be "AtStartOfParagraph".
2460 GetTreeID(), inline_text_data_a.id, 1 /* text_offset */,
2462 EXPECT_TRUE(text_position2->AtEndOfParagraph());
2463 EXPECT_FALSE(text_position2->AtStartOfParagraph());
2464
2465 // Before "some".
2467 GetTreeID(), inline_text_data_b_1.id, 0 /* text_offset */,
2469 EXPECT_FALSE(text_position3->AtEndOfParagraph());
2470 EXPECT_TRUE(text_position3->AtStartOfParagraph());
2471
2472 // After "some".
2474 GetTreeID(), inline_text_data_b_1.id, 4 /* text_offset */,
2476 EXPECT_FALSE(text_position4->AtEndOfParagraph());
2477 EXPECT_FALSE(text_position4->AtStartOfParagraph());
2478
2479 // Before " ".
2481 GetTreeID(), inline_text_data_b_2.id, 0 /* text_offset */,
2483 EXPECT_FALSE(text_position5->AtEndOfParagraph());
2484 EXPECT_FALSE(text_position5->AtStartOfParagraph());
2485
2486 // After " ".
2488 GetTreeID(), inline_text_data_b_2.id, 1 /* text_offset */,
2490 EXPECT_FALSE(text_position6->AtEndOfParagraph());
2491 EXPECT_FALSE(text_position6->AtStartOfParagraph());
2492
2493 // Before "text".
2495 GetTreeID(), inline_text_data_b_3.id, 0 /* text_offset */,
2497 EXPECT_FALSE(text_position7->AtEndOfParagraph());
2498 EXPECT_FALSE(text_position7->AtStartOfParagraph());
2499
2500 // After "text".
2502 GetTreeID(), inline_text_data_b_3.id, 4 /* text_offset */,
2504 EXPECT_FALSE(text_position8->AtEndOfParagraph());
2505 EXPECT_FALSE(text_position8->AtStartOfParagraph());
2506
2507 // Before the second "\n".
2509 GetTreeID(), inline_text_data_c.id, 0 /* text_offset */,
2511 EXPECT_FALSE(text_position9->AtEndOfParagraph());
2512 EXPECT_FALSE(text_position9->AtStartOfParagraph());
2513
2514 // After the second "\n".
2516 GetTreeID(), inline_text_data_c.id, 1 /* text_offset */,
2518 EXPECT_TRUE(text_position10->AtEndOfParagraph());
2519 EXPECT_FALSE(text_position10->AtStartOfParagraph());
2520}

◆ TEST_F() [215/325]

ui::TEST_F ( AXPositionTest  ,
Clone   
)

Definition at line 498 of file ax_node_position_unittest.cc.

498 {
499 TestPositionType null_position = AXNodePosition::CreateNullPosition();
500 ASSERT_NE(nullptr, null_position);
501 TestPositionType copy_position = null_position->Clone();
502 ASSERT_NE(nullptr, copy_position);
503 EXPECT_TRUE(copy_position->IsNullPosition());
504
505 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
506 GetTreeID(), root_.id, 1 /* child_index */);
507 ASSERT_NE(nullptr, tree_position);
508 copy_position = tree_position->Clone();
509 ASSERT_NE(nullptr, copy_position);
510 EXPECT_TRUE(copy_position->IsTreePosition());
511 EXPECT_EQ(root_.id, copy_position->anchor_id());
512 EXPECT_EQ(1, copy_position->child_index());
513 EXPECT_EQ(AXNodePosition::INVALID_OFFSET, copy_position->text_offset());
514
515 tree_position = AXNodePosition::CreateTreePosition(
516 GetTreeID(), root_.id, AXNodePosition::BEFORE_TEXT);
517 ASSERT_NE(nullptr, tree_position);
518 copy_position = tree_position->Clone();
519 ASSERT_NE(nullptr, copy_position);
520 EXPECT_TRUE(copy_position->IsTreePosition());
521 EXPECT_EQ(root_.id, copy_position->anchor_id());
522 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, copy_position->child_index());
523 EXPECT_EQ(AXNodePosition::INVALID_OFFSET, copy_position->text_offset());
524
526 GetTreeID(), text_field_.id, 0 /* text_offset */,
528 ASSERT_NE(nullptr, text_position);
529 ASSERT_TRUE(text_position->IsTextPosition());
530 copy_position = text_position->Clone();
531 ASSERT_NE(nullptr, copy_position);
532 EXPECT_TRUE(copy_position->IsTextPosition());
533 EXPECT_EQ(text_field_.id, copy_position->anchor_id());
534 EXPECT_EQ(0, copy_position->text_offset());
535 EXPECT_EQ(ax::mojom::TextAffinity::kUpstream, copy_position->affinity());
536
538 GetTreeID(), text_field_.id, 0 /* text_offset */,
540 ASSERT_NE(nullptr, text_position);
541 ASSERT_TRUE(text_position->IsTextPosition());
542 copy_position = text_position->Clone();
543 ASSERT_NE(nullptr, copy_position);
544 EXPECT_TRUE(copy_position->IsTextPosition());
545 EXPECT_EQ(text_field_.id, copy_position->anchor_id());
546 EXPECT_EQ(0, copy_position->text_offset());
547 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, copy_position->affinity());
548 EXPECT_EQ(AXNodePosition::INVALID_INDEX, copy_position->child_index());
549}

◆ TEST_F() [216/325]

ui::TEST_F ( AXPositionTest  ,
CreateChildPositionAtWithNullPosition   
)

Definition at line 5144 of file ax_node_position_unittest.cc.

5144 {
5145 TestPositionType null_position = AXNodePosition::CreateNullPosition();
5146 ASSERT_NE(nullptr, null_position);
5147 TestPositionType test_position = null_position->CreateChildPositionAt(0);
5148 EXPECT_NE(nullptr, test_position);
5149 EXPECT_TRUE(test_position->IsNullPosition());
5150}

◆ TEST_F() [217/325]

ui::TEST_F ( AXPositionTest  ,
CreateChildPositionAtWithTextPosition   
)

Definition at line 5172 of file ax_node_position_unittest.cc.

5172 {
5174 GetTreeID(), static_text1_.id, 5 /* text_offset */,
5176 ASSERT_NE(nullptr, text_position);
5177 ASSERT_TRUE(text_position->IsTextPosition());
5178 TestPositionType test_position = text_position->CreateChildPositionAt(0);
5179 EXPECT_NE(nullptr, test_position);
5180 EXPECT_TRUE(test_position->IsTextPosition());
5181 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
5182 EXPECT_EQ(0, test_position->text_offset());
5183
5184 text_position = AXNodePosition::CreateTextPosition(
5185 GetTreeID(), static_text2_.id, 4 /* text_offset */,
5187 ASSERT_NE(nullptr, text_position);
5188 ASSERT_TRUE(text_position->IsTextPosition());
5189 test_position = text_position->CreateChildPositionAt(1);
5190 EXPECT_NE(nullptr, test_position);
5191 EXPECT_TRUE(test_position->IsNullPosition());
5192}

◆ TEST_F() [218/325]

ui::TEST_F ( AXPositionTest  ,
CreateChildPositionAtWithTreePosition   
)

Definition at line 5152 of file ax_node_position_unittest.cc.

5152 {
5153 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
5154 GetTreeID(), root_.id, 2 /* child_index */);
5155 ASSERT_NE(nullptr, tree_position);
5156 TestPositionType test_position = tree_position->CreateChildPositionAt(1);
5157 EXPECT_NE(nullptr, test_position);
5158 EXPECT_TRUE(test_position->IsTreePosition());
5159 EXPECT_EQ(check_box_.id, test_position->anchor_id());
5160 // Since the anchor is a leaf node, |child_index| should signify that this is
5161 // a "before text" position.
5162 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
5163
5164 tree_position = AXNodePosition::CreateTreePosition(GetTreeID(), button_.id,
5165 0 /* child_index */);
5166 ASSERT_NE(nullptr, tree_position);
5167 test_position = tree_position->CreateChildPositionAt(0);
5168 EXPECT_NE(nullptr, test_position);
5169 EXPECT_TRUE(test_position->IsNullPosition());
5170}

◆ TEST_F() [219/325]

ui::TEST_F ( AXPositionTest  ,
CreateLinePositionsMultipleAnchorsInSingleLine   
)

Definition at line 7060 of file ax_node_position_unittest.cc.

7060 {
7061 // This test updates the tree structure to test a specific edge case -
7062 // Create next and previous line start/end positions on a single line composed
7063 // by multiple anchors; only two line boundaries should be resolved: either
7064 // the start of the "before" text or at the end of "after".
7065 // ++1 kRootWebArea
7066 // ++++2 kStaticText
7067 // ++++++3 kInlineTextBox "before" kNextOnLineId=6
7068 // ++++4 kGenericContainer
7069 // ++++++5 kStaticText
7070 // ++++++++6 kInlineTextBox "inside" kPreviousOnLineId=3 kNextOnLineId=8
7071 // ++++7 kStaticText
7072 // ++++++8 kInlineTextBox "after" kPreviousOnLineId=6
7074 AXNodeData inline_box1;
7075 AXNodeData inline_box2;
7076 AXNodeData inline_box3;
7077 AXNodeData inline_block;
7078 AXNodeData static_text1;
7079 AXNodeData static_text2;
7080 AXNodeData static_text3;
7081
7082 root.id = 1;
7083 static_text1.id = 2;
7084 inline_box1.id = 3;
7085 inline_block.id = 4;
7086 static_text2.id = 5;
7087 inline_box2.id = 6;
7088 static_text3.id = 7;
7089 inline_box3.id = 8;
7090
7092 root.child_ids = {static_text1.id, inline_block.id, static_text3.id};
7093
7094 static_text1.role = ax::mojom::Role::kStaticText;
7095 static_text1.SetName("before");
7096 static_text1.child_ids = {inline_box1.id};
7097
7099 inline_box1.SetName("before");
7101 inline_box2.id);
7102
7104 inline_block.child_ids = {static_text2.id};
7105
7106 static_text2.role = ax::mojom::Role::kStaticText;
7107 static_text2.SetName("inside");
7108 static_text2.child_ids = {inline_box2.id};
7109
7111 inline_box2.SetName("inside");
7113 inline_box1.id);
7115 inline_box3.id);
7116
7117 static_text3.role = ax::mojom::Role::kStaticText;
7118 static_text3.SetName("after");
7119 static_text3.child_ids = {inline_box3.id};
7120
7122 inline_box3.SetName("after");
7124 inline_box2.id);
7125
7126 SetTree(CreateAXTree({root, static_text1, inline_box1, inline_block,
7127 static_text2, inline_box2, static_text3, inline_box3}));
7128
7130 GetTreeID(), inline_block.id, 3 /* text_offset */,
7132 ASSERT_NE(nullptr, text_position);
7133 ASSERT_TRUE(text_position->IsTextPosition());
7134
7135 TestPositionType next_line_start_position =
7136 text_position->CreateNextLineStartPosition(
7137 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7138 ASSERT_NE(nullptr, next_line_start_position);
7139 EXPECT_TRUE(next_line_start_position->IsTextPosition());
7140 EXPECT_EQ(inline_box3.id, next_line_start_position->anchor_id());
7141 EXPECT_EQ(5, next_line_start_position->text_offset());
7142
7143 TestPositionType previous_line_start_position =
7144 text_position->CreatePreviousLineStartPosition(
7145 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7146 ASSERT_NE(nullptr, previous_line_start_position);
7147 EXPECT_TRUE(previous_line_start_position->IsTextPosition());
7148 EXPECT_EQ(inline_box1.id, previous_line_start_position->anchor_id());
7149 EXPECT_EQ(0, previous_line_start_position->text_offset());
7150
7151 TestPositionType next_line_end_position =
7152 text_position->CreateNextLineEndPosition(
7153 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7154 ASSERT_NE(nullptr, next_line_end_position);
7155 EXPECT_TRUE(next_line_end_position->IsTextPosition());
7156 EXPECT_EQ(inline_box3.id, next_line_end_position->anchor_id());
7157 EXPECT_EQ(5, next_line_end_position->text_offset());
7158
7159 TestPositionType previous_line_end_position =
7160 text_position->CreatePreviousLineEndPosition(
7161 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7162 ASSERT_NE(nullptr, previous_line_end_position);
7163 EXPECT_TRUE(previous_line_end_position->IsTextPosition());
7164 EXPECT_EQ(inline_box1.id, previous_line_end_position->anchor_id());
7165 EXPECT_EQ(0, previous_line_end_position->text_offset());
7166}

◆ TEST_F() [220/325]

ui::TEST_F ( AXPositionTest  ,
CreateNextAnchorPosition   
)

Definition at line 7017 of file ax_node_position_unittest.cc.

7017 {
7018 // This test updates the tree structure to test a specific edge case -
7019 // CreateNextAnchorPosition on an empty text field.
7020 AXNodeData root_data;
7021 root_data.id = 1;
7023
7024 AXNodeData text_data;
7025 text_data.id = 2;
7027 text_data.SetName("some text");
7028
7029 AXNodeData text_field_data;
7030 text_field_data.id = 3;
7031 text_field_data.role = ax::mojom::Role::kTextField;
7032
7033 AXNodeData empty_text_data;
7034 empty_text_data.id = 4;
7035 empty_text_data.role = ax::mojom::Role::kStaticText;
7036 empty_text_data.SetName("");
7037
7038 AXNodeData more_text_data;
7039 more_text_data.id = 5;
7040 more_text_data.role = ax::mojom::Role::kStaticText;
7041 more_text_data.SetName("more text");
7042
7043 root_data.child_ids = {text_data.id, text_field_data.id, more_text_data.id};
7044 text_field_data.child_ids = {empty_text_data.id};
7045
7046 SetTree(CreateAXTree({root_data, text_data, text_field_data, empty_text_data,
7047 more_text_data}));
7048
7049 // Test that CreateNextAnchorPosition will successfully navigate past the
7050 // empty text field.
7052 GetTreeID(), text_data.id, 8 /* text_offset */,
7054 ASSERT_NE(nullptr, text_position1);
7055 ASSERT_FALSE(text_position1->CreateNextAnchorPosition()
7056 ->CreateNextAnchorPosition()
7057 ->IsNullPosition());
7058}

◆ TEST_F() [221/325]

ui::TEST_F ( AXPositionTest  ,
CreateNextAndPreviousCharacterPositionWithNullPosition   
)

Definition at line 5878 of file ax_node_position_unittest.cc.

5878 {
5879 TestPositionType null_position = AXNodePosition::CreateNullPosition();
5880 ASSERT_NE(nullptr, null_position);
5881 TestPositionType test_position = null_position->CreateNextCharacterPosition(
5882 AXBoundaryBehavior::CrossBoundary);
5883 EXPECT_NE(nullptr, test_position);
5884 EXPECT_TRUE(test_position->IsNullPosition());
5885 test_position = null_position->CreatePreviousCharacterPosition(
5886 AXBoundaryBehavior::CrossBoundary);
5887 EXPECT_NE(nullptr, test_position);
5888 EXPECT_TRUE(test_position->IsNullPosition());
5889}

◆ TEST_F() [222/325]

ui::TEST_F ( AXPositionTest  ,
CreateNextAndPreviousLeafTextPositionWithNullPosition   
)

Definition at line 5262 of file ax_node_position_unittest.cc.

5262 {
5263 TestPositionType null_position = AXNodePosition::CreateNullPosition();
5264 ASSERT_NE(nullptr, null_position);
5265 TestPositionType test_position = null_position->CreateNextLeafTextPosition();
5266 EXPECT_NE(nullptr, test_position);
5267 EXPECT_TRUE(test_position->IsNullPosition());
5268 test_position = null_position->CreatePreviousLeafTextPosition();
5269 EXPECT_NE(nullptr, test_position);
5270 EXPECT_TRUE(test_position->IsNullPosition());
5271}

◆ TEST_F() [223/325]

ui::TEST_F ( AXPositionTest  ,
CreateNextAndPreviousWordEndPositionWithNullPosition   
)

Definition at line 6612 of file ax_node_position_unittest.cc.

6612 {
6613 TestPositionType null_position = AXNodePosition::CreateNullPosition();
6614 ASSERT_NE(nullptr, null_position);
6615 TestPositionType test_position = null_position->CreateNextWordEndPosition(
6616 AXBoundaryBehavior::CrossBoundary);
6617 EXPECT_NE(nullptr, test_position);
6618 EXPECT_TRUE(test_position->IsNullPosition());
6619 test_position = null_position->CreatePreviousWordEndPosition(
6620 AXBoundaryBehavior::CrossBoundary);
6621 EXPECT_NE(nullptr, test_position);
6622 EXPECT_TRUE(test_position->IsNullPosition());
6623}

◆ TEST_F() [224/325]

ui::TEST_F ( AXPositionTest  ,
CreateNextAndPreviousWordStartPositionWithNullPosition   
)

Definition at line 6599 of file ax_node_position_unittest.cc.

6599 {
6600 TestPositionType null_position = AXNodePosition::CreateNullPosition();
6601 ASSERT_NE(nullptr, null_position);
6602 TestPositionType test_position = null_position->CreateNextWordStartPosition(
6603 AXBoundaryBehavior::CrossBoundary);
6604 EXPECT_NE(nullptr, test_position);
6605 EXPECT_TRUE(test_position->IsNullPosition());
6606 test_position = null_position->CreatePreviousWordStartPosition(
6607 AXBoundaryBehavior::CrossBoundary);
6608 EXPECT_NE(nullptr, test_position);
6609 EXPECT_TRUE(test_position->IsNullPosition());
6610}

◆ TEST_F() [225/325]

ui::TEST_F ( AXPositionTest  ,
CreateNextCharacterPosition   
)

Definition at line 6047 of file ax_node_position_unittest.cc.

6047 {
6049 GetTreeID(), inline_box1_.id, 4 /* text_offset */,
6051 ASSERT_NE(nullptr, text_position);
6052 ASSERT_TRUE(text_position->IsTextPosition());
6053
6054 TestPositionType test_position = text_position->CreateNextCharacterPosition(
6055 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6056 EXPECT_NE(nullptr, test_position);
6057 EXPECT_TRUE(test_position->IsTextPosition());
6058 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6059 EXPECT_EQ(4, test_position->text_offset());
6060 test_position = text_position->CreateNextCharacterPosition(
6061 AXBoundaryBehavior::CrossBoundary);
6062 EXPECT_NE(nullptr, test_position);
6063 EXPECT_TRUE(test_position->IsTextPosition());
6064 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6065 EXPECT_EQ(5, test_position->text_offset());
6066 test_position = text_position->CreateNextCharacterPosition(
6067 AXBoundaryBehavior::StopAtAnchorBoundary);
6068 EXPECT_NE(nullptr, test_position);
6069 EXPECT_TRUE(test_position->IsTextPosition());
6070 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6071 EXPECT_EQ(5, test_position->text_offset());
6072 test_position = text_position->CreateNextCharacterPosition(
6073 AXBoundaryBehavior::StopAtLastAnchorBoundary);
6074 EXPECT_NE(nullptr, test_position);
6075 EXPECT_TRUE(test_position->IsTextPosition());
6076 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6077 EXPECT_EQ(5, test_position->text_offset());
6078
6079 text_position = AXNodePosition::CreateTextPosition(
6080 GetTreeID(), inline_box1_.id, 5 /* text_offset */,
6082 ASSERT_NE(nullptr, text_position);
6083 ASSERT_TRUE(text_position->IsTextPosition());
6084
6085 test_position = text_position->CreateNextCharacterPosition(
6086 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6087 EXPECT_NE(nullptr, test_position);
6088 EXPECT_TRUE(test_position->IsTextPosition());
6089 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6090 EXPECT_EQ(5, test_position->text_offset());
6091 test_position = text_position->CreateNextCharacterPosition(
6092 AXBoundaryBehavior::CrossBoundary);
6093 EXPECT_NE(nullptr, test_position);
6094 EXPECT_TRUE(test_position->IsTextPosition());
6095 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6096 EXPECT_EQ(6, test_position->text_offset());
6097 test_position = text_position->CreateNextCharacterPosition(
6098 AXBoundaryBehavior::StopAtAnchorBoundary);
6099 EXPECT_NE(nullptr, test_position);
6100 EXPECT_TRUE(test_position->IsTextPosition());
6101 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6102 EXPECT_EQ(6, test_position->text_offset());
6103 test_position = text_position->CreateNextCharacterPosition(
6104 AXBoundaryBehavior::StopAtLastAnchorBoundary);
6105 EXPECT_NE(nullptr, test_position);
6106 EXPECT_TRUE(test_position->IsTextPosition());
6107 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6108 EXPECT_EQ(6, test_position->text_offset());
6109
6110 text_position = AXNodePosition::CreateTextPosition(
6111 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
6113 ASSERT_NE(nullptr, text_position);
6114 ASSERT_TRUE(text_position->IsTextPosition());
6115
6116 test_position = text_position->CreateNextCharacterPosition(
6117 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6118 EXPECT_NE(nullptr, test_position);
6119 EXPECT_TRUE(test_position->IsTextPosition());
6120 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6121 EXPECT_EQ(6, test_position->text_offset());
6122 test_position = text_position->CreateNextCharacterPosition(
6123 AXBoundaryBehavior::CrossBoundary);
6124 EXPECT_NE(nullptr, test_position);
6125 EXPECT_TRUE(test_position->IsTextPosition());
6126 EXPECT_EQ(line_break_.id, test_position->anchor_id());
6127 EXPECT_EQ(1, test_position->text_offset());
6128 test_position = text_position->CreateNextCharacterPosition(
6129 AXBoundaryBehavior::StopAtAnchorBoundary);
6130 EXPECT_NE(nullptr, test_position);
6131 EXPECT_TRUE(test_position->IsTextPosition());
6132 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6133 EXPECT_EQ(6, test_position->text_offset());
6134 test_position = text_position->CreateNextCharacterPosition(
6135 AXBoundaryBehavior::StopAtLastAnchorBoundary);
6136 EXPECT_NE(nullptr, test_position);
6137 EXPECT_TRUE(test_position->IsTextPosition());
6138 EXPECT_EQ(line_break_.id, test_position->anchor_id());
6139 EXPECT_EQ(1, test_position->text_offset());
6140
6141 text_position = AXNodePosition::CreateTextPosition(
6142 GetTreeID(), inline_box2_.id, 6 /* text_offset */,
6144 ASSERT_NE(nullptr, text_position);
6145 ASSERT_TRUE(text_position->IsTextPosition());
6146
6147 test_position = text_position->CreateNextCharacterPosition(
6148 AXBoundaryBehavior::CrossBoundary);
6149 EXPECT_NE(nullptr, test_position);
6150 EXPECT_TRUE(test_position->IsNullPosition());
6151 test_position = text_position->CreateNextCharacterPosition(
6152 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6153 EXPECT_NE(nullptr, test_position);
6154 EXPECT_TRUE(test_position->IsTextPosition());
6155 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6156 EXPECT_EQ(6, test_position->text_offset());
6157 test_position = text_position->CreateNextCharacterPosition(
6158 AXBoundaryBehavior::StopAtAnchorBoundary);
6159 EXPECT_NE(nullptr, test_position);
6160 EXPECT_TRUE(test_position->IsTextPosition());
6161 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6162 EXPECT_EQ(6, test_position->text_offset());
6163 test_position = text_position->CreateNextCharacterPosition(
6164 AXBoundaryBehavior::StopAtLastAnchorBoundary);
6165 EXPECT_NE(nullptr, test_position);
6166 EXPECT_TRUE(test_position->IsTextPosition());
6167 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6168 EXPECT_EQ(6, test_position->text_offset());
6169
6170 text_position = AXNodePosition::CreateTextPosition(
6171 GetTreeID(), check_box_.id, 0 /* text_offset */,
6173 ASSERT_NE(nullptr, text_position);
6174 ASSERT_TRUE(text_position->IsTextPosition());
6175
6176 test_position = text_position->CreateNextCharacterPosition(
6177 AXBoundaryBehavior::CrossBoundary);
6178 EXPECT_NE(nullptr, test_position);
6179 EXPECT_TRUE(test_position->IsTextPosition());
6180 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6181 EXPECT_EQ(1, test_position->text_offset());
6182 test_position = text_position->CreateNextCharacterPosition(
6183 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6184 EXPECT_NE(nullptr, test_position);
6185 EXPECT_TRUE(test_position->IsTextPosition());
6186 EXPECT_EQ(check_box_.id, test_position->anchor_id());
6187 EXPECT_EQ(0, test_position->text_offset());
6188 test_position = text_position->CreateNextCharacterPosition(
6189 AXBoundaryBehavior::StopAtAnchorBoundary);
6190 EXPECT_NE(nullptr, test_position);
6191 EXPECT_TRUE(test_position->IsTextPosition());
6192 EXPECT_EQ(check_box_.id, test_position->anchor_id());
6193 EXPECT_EQ(0, test_position->text_offset());
6194 test_position = text_position->CreateNextCharacterPosition(
6195 AXBoundaryBehavior::StopAtLastAnchorBoundary);
6196 EXPECT_NE(nullptr, test_position);
6197 EXPECT_TRUE(test_position->IsTextPosition());
6198 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6199 EXPECT_EQ(1, test_position->text_offset());
6200
6201 text_position = AXNodePosition::CreateTextPosition(
6202 GetTreeID(), text_field_.id, 0 /* text_offset */,
6204 ASSERT_NE(nullptr, text_position);
6205 ASSERT_TRUE(text_position->IsTextPosition());
6206
6207 test_position = text_position->CreateNextCharacterPosition(
6208 AXBoundaryBehavior::CrossBoundary);
6209 EXPECT_NE(nullptr, test_position);
6210 EXPECT_TRUE(test_position->IsTextPosition());
6211 EXPECT_EQ(text_field_.id, test_position->anchor_id());
6212 EXPECT_EQ(1, test_position->text_offset());
6213 // Affinity should have been reset to downstream.
6214 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
6215
6216 text_position = AXNodePosition::CreateTextPosition(
6217 GetTreeID(), text_field_.id, 12 /* text_offset */,
6219 ASSERT_NE(nullptr, text_position);
6220 ASSERT_TRUE(text_position->IsTextPosition());
6221
6222 test_position = text_position->CreateNextCharacterPosition(
6223 AXBoundaryBehavior::CrossBoundary);
6224 EXPECT_NE(nullptr, test_position);
6225 EXPECT_TRUE(test_position->IsTextPosition());
6226 EXPECT_EQ(text_field_.id, test_position->anchor_id());
6227 EXPECT_EQ(13, test_position->text_offset());
6228 // Affinity should have been reset to downstream.
6229 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
6230}

◆ TEST_F() [226/325]

ui::TEST_F ( AXPositionTest  ,
CreateNextCharacterPositionAtGraphemeBoundary   
)

Definition at line 6401 of file ax_node_position_unittest.cc.

6401 {
6402#if true
6403 GTEST_SKIP()
6404 << "Skipping, current accessibility library cannot handle grapheme";
6405#else
6406 std::vector<int> text_offsets;
6407 SetTree(CreateMultilingualDocument(&text_offsets));
6408
6410 GetTreeID(), GetTree()->root()->id(), 0 /* text_offset */,
6412 ASSERT_NE(nullptr, test_position);
6413 ASSERT_TRUE(test_position->IsTextPosition());
6414
6415 for (auto iter = (text_offsets.begin() + 1); iter != text_offsets.end();
6416 ++iter) {
6417 const int text_offset = *iter;
6418 test_position = test_position->CreateNextCharacterPosition(
6419 AXBoundaryBehavior::CrossBoundary);
6420 ASSERT_NE(nullptr, test_position);
6421 EXPECT_TRUE(test_position->IsTextPosition());
6422
6423 testing::Message message;
6424 message << "Expecting character boundary at " << text_offset << " in\n"
6425 << *test_position;
6426 SCOPED_TRACE(message);
6427
6428 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
6429 EXPECT_EQ(text_offset, test_position->text_offset());
6430 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
6431 }
6432
6433 test_position = AXNodePosition::CreateTextPosition(
6434 GetTreeID(), GetTree()->root()->id(), 3 /* text_offset */,
6436 test_position = test_position->CreateNextCharacterPosition(
6437 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6438 ASSERT_NE(nullptr, test_position);
6439 EXPECT_TRUE(test_position->IsTextPosition());
6440 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
6441 EXPECT_EQ(3, test_position->text_offset());
6442 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
6443
6444 test_position = AXNodePosition::CreateTextPosition(
6445 GetTreeID(), GetTree()->root()->id(), 4 /* text_offset */,
6447 test_position = test_position->CreateNextCharacterPosition(
6448 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6449 ASSERT_NE(nullptr, test_position);
6450 EXPECT_TRUE(test_position->IsTextPosition());
6451 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
6452 EXPECT_EQ(5, test_position->text_offset());
6453 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
6454
6455 test_position = AXNodePosition::CreateTextPosition(
6456 GetTreeID(), GetTree()->root()->id(), 9 /* text_offset */,
6458 test_position = test_position->CreateNextCharacterPosition(
6459 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6460 ASSERT_NE(nullptr, test_position);
6461 EXPECT_TRUE(test_position->IsTextPosition());
6462 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
6463 EXPECT_EQ(9, test_position->text_offset());
6464 EXPECT_EQ(ax::mojom::TextAffinity::kUpstream, test_position->affinity());
6465
6466 test_position = AXNodePosition::CreateTextPosition(
6467 GetTreeID(), GetTree()->root()->id(), 10 /* text_offset */,
6469 test_position = test_position->CreateNextCharacterPosition(
6470 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6471 ASSERT_NE(nullptr, test_position);
6472 EXPECT_TRUE(test_position->IsTextPosition());
6473 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
6474 EXPECT_EQ(12, test_position->text_offset());
6475 // Affinity should have been reset to downstream because there was a move.
6476 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
6477#endif // true
6478}
Win32Message message

◆ TEST_F() [227/325]

ui::TEST_F ( AXPositionTest  ,
CreateNextLeafTextPosition   
)

Definition at line 5273 of file ax_node_position_unittest.cc.

5273 {
5274 TestPositionType check_box_position = AXNodePosition::CreateTreePosition(
5275 GetTreeID(), root_.id, 1 /* child_index */);
5276 ASSERT_NE(nullptr, check_box_position);
5277 TestPositionType test_position =
5278 check_box_position->CreateNextLeafTextPosition();
5279 EXPECT_NE(nullptr, test_position);
5280 EXPECT_TRUE(test_position->IsTextPosition());
5281 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5282 EXPECT_EQ(check_box_.id, test_position->anchor_id());
5283 EXPECT_EQ(0, test_position->text_offset());
5284
5285 // The text offset on the root points to the button since it is the first
5286 // available leaf text position, even though it has no text content.
5288 GetTreeID(), root_.id, 0 /* text_offset */,
5290 ASSERT_NE(nullptr, root_position);
5291 ASSERT_TRUE(root_position->IsTextPosition());
5292 test_position = root_position->CreateNextLeafTextPosition();
5293 EXPECT_NE(nullptr, test_position);
5294 EXPECT_TRUE(test_position->IsTextPosition());
5295 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5296 EXPECT_EQ(button_.id, test_position->anchor_id());
5297 EXPECT_EQ(0, test_position->text_offset());
5298
5300 GetTreeID(), button_.id, 0 /* text_offset */,
5302 ASSERT_NE(nullptr, button_position);
5303 ASSERT_TRUE(button_position->IsTextPosition());
5304 test_position = button_position->CreateNextLeafTextPosition();
5305 EXPECT_NE(nullptr, test_position);
5306 EXPECT_TRUE(test_position->IsTextPosition());
5307 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5308 EXPECT_EQ(check_box_.id, test_position->anchor_id());
5309 EXPECT_EQ(0, test_position->text_offset());
5310
5311 test_position = test_position->CreateNextLeafTextPosition();
5312 EXPECT_NE(nullptr, test_position);
5313 EXPECT_TRUE(test_position->IsTextPosition());
5314 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5315 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
5316 EXPECT_EQ(0, test_position->text_offset());
5317
5318 test_position = test_position->CreateNextLeafTextPosition();
5319 EXPECT_NE(nullptr, test_position);
5320 EXPECT_TRUE(test_position->IsTextPosition());
5321 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5322 EXPECT_EQ(line_break_.id, test_position->anchor_id());
5323 EXPECT_EQ(0, test_position->text_offset());
5324
5325 test_position = test_position->CreateNextLeafTextPosition();
5326 EXPECT_NE(nullptr, test_position);
5327 EXPECT_TRUE(test_position->IsTextPosition());
5328 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5329 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5330 EXPECT_EQ(0, test_position->text_offset());
5331
5332 test_position = test_position->CreateNextLeafTextPosition();
5333 EXPECT_NE(nullptr, test_position);
5334 EXPECT_TRUE(test_position->IsNullPosition());
5335
5336 TestPositionType text_field_position = AXNodePosition::CreateTreePosition(
5337 GetTreeID(), root_.id, 2 /* child_index */);
5338 ASSERT_NE(nullptr, text_field_position);
5339 test_position = text_field_position->CreateNextLeafTextPosition();
5340 EXPECT_NE(nullptr, test_position);
5341 EXPECT_TRUE(test_position->IsTextPosition());
5342 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5343 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
5344 EXPECT_EQ(0, test_position->text_offset());
5345
5346 // The root text position should resolve to its leaf text position,
5347 // maintaining its text_offset
5349 GetTreeID(), root_.id, 10 /* text_offset */,
5351 ASSERT_NE(nullptr, root_position2);
5352 ASSERT_TRUE(root_position2->IsTextPosition());
5353 test_position = root_position2->CreateNextLeafTextPosition();
5354 EXPECT_NE(nullptr, test_position);
5355 EXPECT_TRUE(test_position->IsTextPosition());
5356 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5357 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5358 EXPECT_EQ(3, test_position->text_offset());
5359}

◆ TEST_F() [228/325]

ui::TEST_F ( AXPositionTest  ,
CreateNextLeafTreePosition   
)

Definition at line 5450 of file ax_node_position_unittest.cc.

5450 {
5451 TestPositionType root_position = AXNodePosition::CreateTreePosition(
5452 GetTreeID(), root_.id, 0 /* child_index */);
5453 ASSERT_TRUE(root_position->IsTreePosition());
5454
5455 TestPositionType button_position = AXNodePosition::CreateTreePosition(
5456 GetTreeID(), button_.id, AXNodePosition::BEFORE_TEXT);
5457 TestPositionType checkbox_position = AXNodePosition::CreateTreePosition(
5458 GetTreeID(), check_box_.id, AXNodePosition::BEFORE_TEXT);
5459 TestPositionType inline_box1_position = AXNodePosition::CreateTreePosition(
5460 GetTreeID(), inline_box1_.id, AXNodePosition::BEFORE_TEXT);
5461 TestPositionType line_break_position = AXNodePosition::CreateTreePosition(
5462 GetTreeID(), line_break_.id, AXNodePosition::BEFORE_TEXT);
5463 TestPositionType inline_box2_position = AXNodePosition::CreateTreePosition(
5464 GetTreeID(), inline_box2_.id, AXNodePosition::BEFORE_TEXT);
5465
5466 TestPositionType test_position = root_position->CreateNextLeafTreePosition();
5467 EXPECT_TRUE(test_position->IsTreePosition());
5468 EXPECT_EQ(*test_position, *button_position);
5469
5470 test_position = test_position->CreateNextLeafTreePosition();
5471 EXPECT_TRUE(test_position->IsTreePosition());
5472 EXPECT_EQ(*test_position, *checkbox_position);
5473
5474 test_position = test_position->CreateNextLeafTreePosition();
5475 EXPECT_TRUE(test_position->IsTreePosition());
5476 EXPECT_EQ(*test_position, *inline_box1_position);
5477
5478 test_position = test_position->CreateNextLeafTreePosition();
5479 EXPECT_TRUE(test_position->IsTreePosition());
5480 EXPECT_EQ(*test_position, *line_break_position);
5481
5482 test_position = test_position->CreateNextLeafTreePosition();
5483 EXPECT_TRUE(test_position->IsTreePosition());
5484 EXPECT_EQ(*test_position, *inline_box2_position);
5485
5486 test_position = test_position->CreateNextLeafTreePosition();
5487 EXPECT_TRUE(test_position->IsNullPosition());
5488
5490 GetTreeID(), root_.id, 2 /* text_offset */,
5492 EXPECT_TRUE(root_text_position->IsTextPosition());
5493
5494 test_position = root_text_position->CreateNextLeafTreePosition();
5495 EXPECT_TRUE(test_position->IsTreePosition());
5496 EXPECT_EQ(*test_position, *inline_box1_position);
5497
5498 TestPositionType inline_box1_text_position =
5499 AXNodePosition::CreateTextPosition(GetTreeID(), inline_box1_.id,
5500 2 /* text_offset */,
5502 EXPECT_TRUE(inline_box1_text_position->IsTextPosition());
5503
5504 test_position = inline_box1_text_position->CreateNextLeafTreePosition();
5505 EXPECT_TRUE(test_position->IsTreePosition());
5506 EXPECT_EQ(*test_position, *line_break_position);
5507}

◆ TEST_F() [229/325]

ui::TEST_F ( AXPositionTest  ,
CreateNextWordPositionInList   
)

Definition at line 7168 of file ax_node_position_unittest.cc.

7168 {
7169 // This test updates the tree structure to test a specific edge case -
7170 // next word navigation inside a list with AXListMarkers nodes.
7171 // ++1 kRootWebArea
7172 // ++++2 kList
7173 // ++++++3 kListItem
7174 // ++++++++4 kListMarker
7175 // ++++++++++5 kStaticText
7176 // ++++++++++++6 kInlineTextBox "1. "
7177 // ++++++++7 kStaticText
7178 // ++++++++++8 kInlineTextBox "first item"
7179 // ++++++9 kListItem
7180 // ++++++++10 kListMarker
7181 // +++++++++++11 kStaticText
7182 // ++++++++++++++12 kInlineTextBox "2. "
7183 // ++++++++13 kStaticText
7184 // ++++++++++14 kInlineTextBox "second item"
7186 AXNodeData list;
7187 AXNodeData list_item1;
7188 AXNodeData list_item2;
7189 AXNodeData list_marker1;
7190 AXNodeData list_marker2;
7191 AXNodeData inline_box1;
7192 AXNodeData inline_box2;
7193 AXNodeData inline_box3;
7194 AXNodeData inline_box4;
7195 AXNodeData static_text1;
7196 AXNodeData static_text2;
7197 AXNodeData static_text3;
7198 AXNodeData static_text4;
7199
7200 root.id = 1;
7201 list.id = 2;
7202 list_item1.id = 3;
7203 list_marker1.id = 4;
7204 static_text1.id = 5;
7205 inline_box1.id = 6;
7206 static_text2.id = 7;
7207 inline_box2.id = 8;
7208 list_item2.id = 9;
7209 list_marker2.id = 10;
7210 static_text3.id = 11;
7211 inline_box3.id = 12;
7212 static_text4.id = 13;
7213 inline_box4.id = 14;
7214
7216 root.child_ids = {list.id};
7217
7219 list.child_ids = {list_item1.id, list_item2.id};
7220
7221 list_item1.role = ax::mojom::Role::kListItem;
7222 list_item1.child_ids = {list_marker1.id, static_text2.id};
7224 true);
7225
7226 list_marker1.role = ax::mojom::Role::kListMarker;
7227 list_marker1.child_ids = {static_text1.id};
7228
7229 static_text1.role = ax::mojom::Role::kStaticText;
7230 static_text1.SetName("1. ");
7231 static_text1.child_ids = {inline_box1.id};
7232
7234 inline_box1.SetName("1. ");
7236 std::vector<int32_t>{0});
7238 std::vector<int32_t>{3});
7239
7240 static_text2.role = ax::mojom::Role::kStaticText;
7241 static_text2.SetName("first item");
7242 static_text2.child_ids = {inline_box2.id};
7243
7245 inline_box2.SetName("first item");
7247 std::vector<int32_t>{0, 6});
7249 std::vector<int32_t>{5});
7250
7251 list_item2.role = ax::mojom::Role::kListItem;
7252 list_item2.child_ids = {list_marker2.id, static_text4.id};
7254 true);
7255
7256 list_marker2.role = ax::mojom::Role::kListMarker;
7257 list_marker2.child_ids = {static_text3.id};
7258
7259 static_text3.role = ax::mojom::Role::kStaticText;
7260 static_text3.SetName("2. ");
7261 static_text3.child_ids = {inline_box3.id};
7262
7264 inline_box3.SetName("2. ");
7266 std::vector<int32_t>{0});
7268 std::vector<int32_t>{3});
7269
7270 static_text4.role = ax::mojom::Role::kStaticText;
7271 static_text4.SetName("second item");
7272 static_text4.child_ids = {inline_box4.id};
7273
7275 inline_box4.SetName("second item");
7277 std::vector<int32_t>{0, 7});
7279 std::vector<int32_t>{6});
7280
7281 SetTree(CreateAXTree({root, list, list_item1, list_marker1, static_text1,
7282 inline_box1, static_text2, inline_box2, list_item2,
7283 list_marker2, static_text3, inline_box3, static_text4,
7284 inline_box4}));
7285
7287 GetTreeID(), inline_box1.id, 0 /* text_offset */,
7289 ASSERT_NE(nullptr, text_position);
7290 ASSERT_TRUE(text_position->IsTextPosition());
7291 ASSERT_EQ(inline_box1.id, text_position->anchor_id());
7292 ASSERT_EQ(0, text_position->text_offset());
7293
7294 // "1. <f>irst item\n2. second item"
7295 text_position = text_position->CreateNextWordStartPosition(
7296 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7297 ASSERT_NE(nullptr, text_position);
7298 ASSERT_TRUE(text_position->IsTextPosition());
7299 ASSERT_EQ(inline_box2.id, text_position->anchor_id());
7300 ASSERT_EQ(0, text_position->text_offset());
7301
7302 // "1. first <i>tem\n2. second item"
7303 text_position = text_position->CreateNextWordStartPosition(
7304 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7305 ASSERT_NE(nullptr, text_position);
7306 ASSERT_TRUE(text_position->IsTextPosition());
7307 ASSERT_EQ(inline_box2.id, text_position->anchor_id());
7308 ASSERT_EQ(6, text_position->text_offset());
7309
7310 // "1. first item\n<2>. second item"
7311 text_position = text_position->CreateNextWordStartPosition(
7312 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7313 ASSERT_NE(nullptr, text_position);
7314 ASSERT_TRUE(text_position->IsTextPosition());
7315 ASSERT_EQ(inline_box3.id, text_position->anchor_id());
7316 ASSERT_EQ(0, text_position->text_offset());
7317
7318 // "1. first item\n2. <s>econd item"
7319 text_position = text_position->CreateNextWordStartPosition(
7320 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7321 ASSERT_NE(nullptr, text_position);
7322 ASSERT_TRUE(text_position->IsTextPosition());
7323 ASSERT_EQ(inline_box4.id, text_position->anchor_id());
7324 ASSERT_EQ(0, text_position->text_offset());
7325
7326 // "1. first item\n2. second <i>tem"
7327 text_position = text_position->CreateNextWordStartPosition(
7328 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7329 ASSERT_NE(nullptr, text_position);
7330 ASSERT_TRUE(text_position->IsTextPosition());
7331 ASSERT_EQ(inline_box4.id, text_position->anchor_id());
7332 ASSERT_EQ(7, text_position->text_offset());
7333}

◆ TEST_F() [230/325]

ui::TEST_F ( AXPositionTest  ,
CreatePagePositionWithNonPaginatedDocument   
)

Definition at line 4949 of file ax_node_position_unittest.cc.

4949 {
4951 GetTreeID(), static_text1_.id, 0 /* text_offset */,
4953 ASSERT_NE(nullptr, text_position);
4954
4955 // Non-paginated documents should move to the start of the document for
4956 // CreatePreviousPageStartPosition (treating the entire document as a single
4957 // page)
4958 TestPositionType test_position =
4959 text_position->CreatePreviousPageStartPosition(
4960 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4961 EXPECT_NE(nullptr, test_position);
4962 EXPECT_TRUE(test_position->IsTextPosition());
4963 EXPECT_EQ(button_.id, test_position->anchor_id());
4964 EXPECT_EQ(0, test_position->text_offset());
4965
4966 // Since there is no next page, CreateNextPageStartPosition should return a
4967 // null position
4968 test_position = text_position->CreateNextPageStartPosition(
4969 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4970 EXPECT_NE(nullptr, test_position);
4971 EXPECT_TRUE(test_position->IsNullPosition());
4972
4973 // Since there is no previous page, CreatePreviousPageEndPosition should
4974 // return a null position
4975 test_position = text_position->CreatePreviousPageEndPosition(
4976 AXBoundaryBehavior::CrossBoundary);
4977 EXPECT_NE(nullptr, test_position);
4978 EXPECT_TRUE(test_position->IsNullPosition());
4979
4980 // Since there are no distinct pages, CreateNextPageEndPosition should move
4981 // to the end of the document, as if it's one large page.
4982 test_position = text_position->CreateNextPageEndPosition(
4983 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4984 EXPECT_NE(nullptr, test_position);
4985 EXPECT_TRUE(test_position->IsTextPosition());
4986 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
4987 EXPECT_EQ(6, test_position->text_offset());
4988
4989 // CreatePreviousPageStartPosition should move back to the beginning of the
4990 // document
4991 test_position = test_position->CreatePreviousPageStartPosition(
4992 AXBoundaryBehavior::CrossBoundary);
4993 EXPECT_NE(nullptr, test_position);
4994 EXPECT_TRUE(test_position->IsTextPosition());
4995 EXPECT_EQ(button_.id, test_position->anchor_id());
4996 EXPECT_EQ(0, test_position->text_offset());
4997
4998 // Since there's no next page, CreateNextPageStartPosition should return a
4999 // null position
5000 test_position = test_position->CreateNextPageStartPosition(
5001 AXBoundaryBehavior::CrossBoundary);
5002 EXPECT_NE(nullptr, test_position);
5003 EXPECT_TRUE(test_position->IsNullPosition());
5004
5005 // Since there's no previous page, CreatePreviousPageEndPosition should return
5006 // a null position
5007 test_position = text_position->CreatePreviousPageEndPosition(
5008 AXBoundaryBehavior::CrossBoundary);
5009 EXPECT_NE(nullptr, test_position);
5010 EXPECT_TRUE(test_position->IsNullPosition());
5011
5012 // Since there's no previous page, CreatePreviousPageStartPosition should
5013 // return a null position
5014 test_position = text_position->CreatePreviousPageStartPosition(
5015 AXBoundaryBehavior::CrossBoundary);
5016 EXPECT_NE(nullptr, test_position);
5017 EXPECT_TRUE(test_position->IsNullPosition());
5018}

◆ TEST_F() [231/325]

ui::TEST_F ( AXPositionTest  ,
CreatePagePositionWithNullPosition   
)

Definition at line 4915 of file ax_node_position_unittest.cc.

4915 {
4916 TestPositionType null_position = AXNodePosition::CreateNullPosition();
4917 ASSERT_NE(nullptr, null_position);
4918 TestPositionType test_position =
4919 null_position->CreatePreviousPageStartPosition(
4920 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4921 EXPECT_NE(nullptr, test_position);
4922 EXPECT_TRUE(test_position->IsNullPosition());
4923
4924 test_position = null_position->CreateNextPageStartPosition(
4925 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4926 EXPECT_NE(nullptr, test_position);
4927 EXPECT_TRUE(test_position->IsNullPosition());
4928
4929 test_position = null_position->CreatePreviousPageEndPosition(
4930 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4931 EXPECT_NE(nullptr, test_position);
4932 EXPECT_TRUE(test_position->IsNullPosition());
4933
4934 test_position = null_position->CreatePreviousPageStartPosition(
4935 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4936 EXPECT_NE(nullptr, test_position);
4937 EXPECT_TRUE(test_position->IsNullPosition());
4938}

◆ TEST_F() [232/325]

ui::TEST_F ( AXPositionTest  ,
CreateParentPositionWithNullPosition   
)

Definition at line 5194 of file ax_node_position_unittest.cc.

5194 {
5195 TestPositionType null_position = AXNodePosition::CreateNullPosition();
5196 ASSERT_NE(nullptr, null_position);
5197 TestPositionType test_position = null_position->CreateParentPosition();
5198 EXPECT_NE(nullptr, test_position);
5199 EXPECT_TRUE(test_position->IsNullPosition());
5200}

◆ TEST_F() [233/325]

ui::TEST_F ( AXPositionTest  ,
CreateParentPositionWithTextPosition   
)

Definition at line 5222 of file ax_node_position_unittest.cc.

5222 {
5223 // Create a position that points at the end of the first line, right after the
5224 // check box.
5226 GetTreeID(), check_box_.id, 0 /* text_offset */,
5228 ASSERT_NE(nullptr, text_position);
5229 ASSERT_TRUE(text_position->IsTextPosition());
5230 TestPositionType test_position = text_position->CreateParentPosition();
5231 EXPECT_NE(nullptr, test_position);
5232 EXPECT_TRUE(test_position->IsTextPosition());
5233 EXPECT_EQ(root_.id, test_position->anchor_id());
5234 EXPECT_EQ(0, test_position->text_offset());
5235 // Since the same text offset in the root could be used to point to the
5236 // beginning of the second line, affinity should have been adjusted to
5237 // upstream.
5238 EXPECT_EQ(ax::mojom::TextAffinity::kUpstream, test_position->affinity());
5239
5240 text_position = AXNodePosition::CreateTextPosition(
5241 GetTreeID(), inline_box2_.id, 5 /* text_offset */,
5243 ASSERT_NE(nullptr, text_position);
5244 ASSERT_TRUE(text_position->IsTextPosition());
5245 test_position = text_position->CreateParentPosition();
5246 EXPECT_NE(nullptr, test_position);
5247 EXPECT_TRUE(test_position->IsTextPosition());
5248 EXPECT_EQ(static_text2_.id, test_position->anchor_id());
5249 EXPECT_EQ(5, test_position->text_offset());
5250 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
5251
5252 test_position = test_position->CreateParentPosition();
5253 EXPECT_NE(nullptr, test_position);
5254 EXPECT_TRUE(test_position->IsTextPosition());
5255 EXPECT_EQ(text_field_.id, test_position->anchor_id());
5256 // |text_offset| should point to the same offset on the second line where the
5257 // static text node position was pointing at.
5258 EXPECT_EQ(12, test_position->text_offset());
5259 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
5260}

◆ TEST_F() [234/325]

ui::TEST_F ( AXPositionTest  ,
CreateParentPositionWithTreePosition   
)

Definition at line 5202 of file ax_node_position_unittest.cc.

5202 {
5203 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
5204 GetTreeID(), check_box_.id, 0 /* child_index */);
5205 ASSERT_NE(nullptr, tree_position);
5206 TestPositionType test_position = tree_position->CreateParentPosition();
5207 EXPECT_NE(nullptr, test_position);
5208 EXPECT_TRUE(test_position->IsTreePosition());
5209 EXPECT_EQ(root_.id, test_position->anchor_id());
5210 // |child_index| should point to the check box node.
5211 EXPECT_EQ(1, test_position->child_index());
5212 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
5213
5214 tree_position = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
5215 1 /* child_index */);
5216 ASSERT_NE(nullptr, tree_position);
5217 test_position = tree_position->CreateParentPosition();
5218 EXPECT_NE(nullptr, test_position);
5219 EXPECT_TRUE(test_position->IsNullPosition());
5220}

◆ TEST_F() [235/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtEndOfAnchorWithNullPosition   
)

Definition at line 3987 of file ax_node_position_unittest.cc.

3987 {
3988 TestPositionType null_position = AXNodePosition::CreateNullPosition();
3989 ASSERT_NE(nullptr, null_position);
3990 TestPositionType test_position = null_position->CreatePositionAtEndOfAnchor();
3991 EXPECT_NE(nullptr, test_position);
3992 EXPECT_TRUE(test_position->IsNullPosition());
3993}

◆ TEST_F() [236/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtEndOfAnchorWithTextPosition   
)

Definition at line 4015 of file ax_node_position_unittest.cc.

4015 {
4017 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
4019 ASSERT_NE(nullptr, text_position);
4020 ASSERT_TRUE(text_position->IsTextPosition());
4021 TestPositionType test_position = text_position->CreatePositionAtEndOfAnchor();
4022 EXPECT_NE(nullptr, test_position);
4023 EXPECT_TRUE(test_position->IsTextPosition());
4024 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
4025 EXPECT_EQ(6, test_position->text_offset());
4026 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
4027
4028 text_position = AXNodePosition::CreateTextPosition(
4029 GetTreeID(), inline_box1_.id, 5 /* text_offset */,
4031 ASSERT_NE(nullptr, text_position);
4032 ASSERT_TRUE(text_position->IsTextPosition());
4033 test_position = text_position->CreatePositionAtEndOfAnchor();
4034 EXPECT_NE(nullptr, test_position);
4035 EXPECT_TRUE(test_position->IsTextPosition());
4036 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
4037 EXPECT_EQ(6, test_position->text_offset());
4038 // Affinity should have been reset to the default value.
4039 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
4040}

◆ TEST_F() [237/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtEndOfAnchorWithTreePosition   
)

Definition at line 3995 of file ax_node_position_unittest.cc.

3995 {
3996 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
3997 GetTreeID(), root_.id, 3 /* child_index */);
3998 ASSERT_NE(nullptr, tree_position);
3999 TestPositionType test_position = tree_position->CreatePositionAtEndOfAnchor();
4000 EXPECT_NE(nullptr, test_position);
4001 EXPECT_TRUE(test_position->IsTreePosition());
4002 EXPECT_EQ(root_.id, test_position->anchor_id());
4003 EXPECT_EQ(3, test_position->child_index());
4004
4005 tree_position = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
4006 1 /* child_index */);
4007 ASSERT_NE(nullptr, tree_position);
4008 test_position = tree_position->CreatePositionAtEndOfAnchor();
4009 EXPECT_NE(nullptr, test_position);
4010 EXPECT_TRUE(test_position->IsTreePosition());
4011 EXPECT_EQ(root_.id, test_position->anchor_id());
4012 EXPECT_EQ(3, test_position->child_index());
4013}

◆ TEST_F() [238/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtEndOfDocumentWithNullPosition   
)

Definition at line 5065 of file ax_node_position_unittest.cc.

5065 {
5066 TestPositionType null_position = AXNodePosition::CreateNullPosition();
5067 ASSERT_NE(nullptr, null_position);
5068 TestPositionType test_position =
5069 null_position->CreatePositionAtEndOfDocument();
5070 EXPECT_NE(nullptr, test_position);
5071 EXPECT_TRUE(test_position->IsNullPosition());
5072}

◆ TEST_F() [239/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtEndOfDocumentWithTextPosition   
)

Definition at line 5098 of file ax_node_position_unittest.cc.

5098 {
5100 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
5102 ASSERT_NE(nullptr, text_position);
5103 TestPositionType test_position =
5104 text_position->CreatePositionAtEndOfDocument();
5105 EXPECT_NE(nullptr, test_position);
5106 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5107
5108 text_position = AXNodePosition::CreateTextPosition(
5109 GetTreeID(), inline_box1_.id, 5 /* text_offset */,
5111 ASSERT_NE(nullptr, text_position);
5112 test_position = text_position->CreatePositionAtEndOfDocument();
5113 EXPECT_NE(nullptr, test_position);
5114 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5115 // Affinity should have been reset to the default value.
5116 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
5117}

◆ TEST_F() [240/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtEndOfDocumentWithTreePosition   
)

Definition at line 5074 of file ax_node_position_unittest.cc.

5074 {
5075 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
5076 GetTreeID(), root_.id, 3 /* child_index */);
5077 ASSERT_NE(nullptr, tree_position);
5078 TestPositionType test_position =
5079 tree_position->CreatePositionAtEndOfDocument();
5080 EXPECT_NE(nullptr, test_position);
5081 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5082
5083 tree_position = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
5084 1 /* child_index */);
5085 ASSERT_NE(nullptr, tree_position);
5086 test_position = tree_position->CreatePositionAtEndOfDocument();
5087 EXPECT_NE(nullptr, test_position);
5088 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5089
5090 tree_position = AXNodePosition::CreateTreePosition(
5091 GetTreeID(), inline_box1_.id, 0 /* child_index */);
5092 ASSERT_NE(nullptr, tree_position);
5093 test_position = tree_position->CreatePositionAtEndOfDocument();
5094 EXPECT_NE(nullptr, test_position);
5095 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5096}

◆ TEST_F() [241/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtFormatBoundaryWithTextPosition   
)

Definition at line 4292 of file ax_node_position_unittest.cc.

4292 {
4293 // This test updates the tree structure to test a specific edge case -
4294 // CreatePositionAtFormatBoundary when text lies at the beginning and end
4295 // of the AX tree.
4296 AXNodeData root_data;
4297 root_data.id = 1;
4299
4300 AXNodeData text_data;
4301 text_data.id = 2;
4303 text_data.SetName("some text");
4304
4305 AXNodeData more_text_data;
4306 more_text_data.id = 3;
4307 more_text_data.role = ax::mojom::Role::kStaticText;
4308 more_text_data.SetName("more text");
4309
4310 root_data.child_ids = {text_data.id, more_text_data.id};
4311
4312 SetTree(CreateAXTree({root_data, text_data, more_text_data}));
4313
4314 // Test CreatePreviousFormatStartPosition at the start of the document.
4316 GetTreeID(), text_data.id, 8 /* text_offset */,
4318 ASSERT_NE(nullptr, text_position);
4319 TestPositionType test_position =
4320 text_position->CreatePreviousFormatStartPosition(
4321 AXBoundaryBehavior::CrossBoundary);
4322 EXPECT_NE(nullptr, test_position);
4323 EXPECT_TRUE(test_position->IsTextPosition());
4324 EXPECT_EQ(text_data.id, test_position->anchor_id());
4325 EXPECT_EQ(0, test_position->text_offset());
4326
4327 // Test CreateNextFormatEndPosition at the end of the document.
4328 text_position = AXNodePosition::CreateTextPosition(
4329 GetTreeID(), more_text_data.id, 0 /* text_offset */,
4331 ASSERT_NE(nullptr, text_position);
4332 test_position = text_position->CreateNextFormatEndPosition(
4333 AXBoundaryBehavior::CrossBoundary);
4334 EXPECT_NE(nullptr, test_position);
4335 EXPECT_TRUE(test_position->IsTextPosition());
4336 EXPECT_EQ(more_text_data.id, test_position->anchor_id());
4337 EXPECT_EQ(9, test_position->text_offset());
4338}

◆ TEST_F() [242/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtInvalidGraphemeBoundary   
)

Definition at line 3896 of file ax_node_position_unittest.cc.

3896 {
3897 std::vector<int> text_offsets;
3898 SetTree(CreateMultilingualDocument(&text_offsets));
3899
3901 GetTreeID(), GetTree()->root()->id(), 4 /* text_offset */,
3903 ASSERT_NE(nullptr, test_position);
3904 EXPECT_TRUE(test_position->IsTextPosition());
3905 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
3906 EXPECT_EQ(4, test_position->text_offset());
3907 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3908
3909 test_position = AXNodePosition::CreateTextPosition(
3910 GetTreeID(), GetTree()->root()->id(), 10 /* text_offset */,
3912 ASSERT_NE(nullptr, test_position);
3913 EXPECT_TRUE(test_position->IsTextPosition());
3914 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
3915 EXPECT_EQ(10, test_position->text_offset());
3916 EXPECT_EQ(ax::mojom::TextAffinity::kUpstream, test_position->affinity());
3917}

◆ TEST_F() [243/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtNextFormatEndWithNullPosition   
)

Definition at line 4164 of file ax_node_position_unittest.cc.

4164 {
4165 TestPositionType null_position = AXNodePosition::CreateNullPosition();
4166 ASSERT_NE(nullptr, null_position);
4167 TestPositionType test_position = null_position->CreateNextFormatEndPosition(
4168 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4169 EXPECT_NE(nullptr, test_position);
4170 EXPECT_TRUE(test_position->IsNullPosition());
4171 test_position = null_position->CreateNextFormatEndPosition(
4172 AXBoundaryBehavior::CrossBoundary);
4173 EXPECT_NE(nullptr, test_position);
4174 EXPECT_TRUE(test_position->IsNullPosition());
4175}

◆ TEST_F() [244/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtNextFormatEndWithTextPosition   
)

Definition at line 4234 of file ax_node_position_unittest.cc.

4234 {
4236 GetTreeID(), button_.id, 0 /* text_offset */,
4238 ASSERT_NE(nullptr, text_position);
4239 ASSERT_TRUE(text_position->IsTextPosition());
4240
4241 TestPositionType test_position = text_position->CreateNextFormatEndPosition(
4242 AXBoundaryBehavior::CrossBoundary);
4243 EXPECT_NE(nullptr, test_position);
4244 EXPECT_TRUE(test_position->IsTextPosition());
4245 EXPECT_EQ(check_box_.id, test_position->anchor_id());
4246 EXPECT_EQ(0, test_position->text_offset());
4247
4248 test_position = test_position->CreateNextFormatEndPosition(
4249 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4250 EXPECT_NE(nullptr, test_position);
4251 EXPECT_TRUE(test_position->IsTextPosition());
4252 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
4253 EXPECT_EQ(6, test_position->text_offset());
4254
4255 test_position = test_position->CreateNextFormatEndPosition(
4256 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4257 EXPECT_NE(nullptr, test_position);
4258 EXPECT_TRUE(test_position->IsTextPosition());
4259 EXPECT_EQ(line_break_.id, test_position->anchor_id());
4260 EXPECT_EQ(1, test_position->text_offset());
4261
4262 test_position = test_position->CreateNextFormatEndPosition(
4263 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4264 EXPECT_NE(nullptr, test_position);
4265 EXPECT_TRUE(test_position->IsTextPosition());
4266 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
4267 EXPECT_EQ(6, test_position->text_offset());
4268
4269 // StopIfAlreadyAtBoundary shouldn't move, since it's already at a boundary.
4270 test_position = test_position->CreateNextFormatEndPosition(
4271 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4272 EXPECT_NE(nullptr, test_position);
4273 EXPECT_TRUE(test_position->IsTextPosition());
4274 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
4275 EXPECT_EQ(6, test_position->text_offset());
4276
4277 // StopAtLastAnchorBoundary should stop at the end of the document while
4278 // CrossBoundary should return a null position when crossing it.
4279 test_position = test_position->CreateNextFormatEndPosition(
4280 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4281 EXPECT_NE(nullptr, test_position);
4282 EXPECT_TRUE(test_position->IsTextPosition());
4283 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
4284 EXPECT_EQ(6, test_position->text_offset());
4285
4286 test_position = test_position->CreateNextFormatEndPosition(
4287 AXBoundaryBehavior::CrossBoundary);
4288 EXPECT_NE(nullptr, test_position);
4289 EXPECT_TRUE(test_position->IsNullPosition());
4290}

◆ TEST_F() [245/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtNextFormatEndWithTreePosition   
)

Definition at line 4177 of file ax_node_position_unittest.cc.

4177 {
4178 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
4179 GetTreeID(), button_.id, 0 /* child_index */);
4180 ASSERT_NE(nullptr, tree_position);
4181 ASSERT_TRUE(tree_position->IsTreePosition());
4182
4183 TestPositionType test_position = tree_position->CreateNextFormatEndPosition(
4184 AXBoundaryBehavior::CrossBoundary);
4185 EXPECT_NE(nullptr, test_position);
4186 EXPECT_TRUE(test_position->IsTreePosition());
4187 EXPECT_EQ(check_box_.id, test_position->anchor_id());
4188 EXPECT_EQ(0, test_position->child_index());
4189
4190 test_position = test_position->CreateNextFormatEndPosition(
4191 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4192 EXPECT_NE(nullptr, test_position);
4193 EXPECT_TRUE(test_position->IsTreePosition());
4194 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
4195 EXPECT_EQ(0, test_position->child_index());
4196
4197 test_position = test_position->CreateNextFormatEndPosition(
4198 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4199 EXPECT_NE(nullptr, test_position);
4200 EXPECT_TRUE(test_position->IsTreePosition());
4201 EXPECT_EQ(line_break_.id, test_position->anchor_id());
4202 EXPECT_EQ(0, test_position->child_index());
4203
4204 test_position = test_position->CreateNextFormatEndPosition(
4205 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4206 EXPECT_NE(nullptr, test_position);
4207 EXPECT_TRUE(test_position->IsTreePosition());
4208 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
4209 EXPECT_EQ(0, test_position->child_index());
4210
4211 // StopIfAlreadyAtBoundary shouldn't move, since it's already at a boundary.
4212 test_position = test_position->CreateNextFormatEndPosition(
4213 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4214 EXPECT_NE(nullptr, test_position);
4215 EXPECT_TRUE(test_position->IsTreePosition());
4216 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
4217 EXPECT_EQ(0, test_position->child_index());
4218
4219 // StopAtLastAnchorBoundary should stop at the end of the document while
4220 // CrossBoundary should return a null position when crossing it.
4221 test_position = test_position->CreateNextFormatEndPosition(
4222 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4223 EXPECT_NE(nullptr, test_position);
4224 EXPECT_TRUE(test_position->IsTreePosition());
4225 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
4226 EXPECT_EQ(0, test_position->child_index());
4227
4228 test_position = test_position->CreateNextFormatEndPosition(
4229 AXBoundaryBehavior::CrossBoundary);
4230 EXPECT_NE(nullptr, test_position);
4231 EXPECT_TRUE(test_position->IsNullPosition());
4232}

◆ TEST_F() [246/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtPageBoundaryWithTextPosition   
)

Definition at line 4608 of file ax_node_position_unittest.cc.

4608 {
4609 AXNodeData root_data, page_1_data, page_1_text_data, page_2_data,
4610 page_2_text_data, page_3_data, page_3_text_data;
4611 SetTree(CreateMultipageDocument(root_data, page_1_data, page_1_text_data,
4612 page_2_data, page_2_text_data, page_3_data,
4613 page_3_text_data));
4614
4615 // Test CreateNextPageStartPosition at the start of the document.
4617 GetTreeID(), page_1_text_data.id, 0 /* text_offset */,
4619 ASSERT_NE(nullptr, text_position);
4620 ASSERT_TRUE(text_position->IsTextPosition());
4621
4622 // StopIfAlreadyAtBoundary shouldn't move at all since it's at a boundary.
4623 TestPositionType test_position = text_position->CreateNextPageStartPosition(
4624 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4625 EXPECT_NE(nullptr, test_position);
4626 EXPECT_TRUE(test_position->IsTextPosition());
4627 EXPECT_EQ(page_1_text_data.id, test_position->anchor_id());
4628 EXPECT_EQ(0, test_position->text_offset());
4629
4630 test_position = text_position->CreateNextPageStartPosition(
4631 AXBoundaryBehavior::CrossBoundary);
4632 EXPECT_NE(nullptr, test_position);
4633 EXPECT_TRUE(test_position->IsTextPosition());
4634 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4635 EXPECT_EQ(0, test_position->text_offset());
4636
4637 test_position = text_position->CreateNextPageStartPosition(
4638 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4639 EXPECT_NE(nullptr, test_position);
4640 EXPECT_TRUE(test_position->IsTextPosition());
4641 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4642 EXPECT_EQ(0, test_position->text_offset());
4643
4644 // Test CreateNextPageEndPosition until the end of document is reached.
4645 test_position = test_position->CreateNextPageEndPosition(
4646 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4647 EXPECT_NE(nullptr, test_position);
4648 EXPECT_TRUE(test_position->IsTextPosition());
4649 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4650 EXPECT_EQ(19, test_position->text_offset());
4651
4652 test_position = test_position->CreateNextPageEndPosition(
4653 AXBoundaryBehavior::CrossBoundary);
4654 EXPECT_NE(nullptr, test_position);
4655 EXPECT_TRUE(test_position->IsTextPosition());
4656 EXPECT_EQ(page_3_text_data.id, test_position->anchor_id());
4657 EXPECT_EQ(24, test_position->text_offset());
4658
4659 test_position = test_position->CreateNextPageEndPosition(
4660 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4661 EXPECT_NE(nullptr, test_position);
4662 EXPECT_TRUE(test_position->IsTextPosition());
4663 EXPECT_EQ(page_3_text_data.id, test_position->anchor_id());
4664 EXPECT_EQ(24, test_position->text_offset());
4665
4666 // StopAtLastAnchorBoundary shouldn't move past the end of the document.
4667 test_position = test_position->CreateNextPageStartPosition(
4668 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4669 EXPECT_NE(nullptr, test_position);
4670 EXPECT_TRUE(test_position->IsTextPosition());
4671 EXPECT_EQ(page_3_text_data.id, test_position->anchor_id());
4672 EXPECT_EQ(24, test_position->text_offset());
4673
4674 test_position = test_position->CreateNextPageEndPosition(
4675 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4676 EXPECT_NE(nullptr, test_position);
4677 EXPECT_TRUE(test_position->IsTextPosition());
4678 EXPECT_EQ(page_3_text_data.id, test_position->anchor_id());
4679 EXPECT_EQ(24, test_position->text_offset());
4680
4681 // Moving forward past the end should return a null position.
4682 TestPositionType null_position = test_position->CreateNextPageStartPosition(
4683 AXBoundaryBehavior::CrossBoundary);
4684 EXPECT_NE(nullptr, null_position);
4685 EXPECT_TRUE(null_position->IsNullPosition());
4686
4687 null_position = test_position->CreateNextPageEndPosition(
4688 AXBoundaryBehavior::CrossBoundary);
4689 EXPECT_NE(nullptr, null_position);
4690 EXPECT_TRUE(null_position->IsNullPosition());
4691
4692 // Now move backward through the document.
4693 text_position = test_position->CreatePreviousPageEndPosition(
4694 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4695 EXPECT_NE(nullptr, text_position);
4696 EXPECT_TRUE(text_position->IsTextPosition());
4697 EXPECT_EQ(page_3_text_data.id, text_position->anchor_id());
4698 EXPECT_EQ(24, text_position->text_offset());
4699
4700 test_position = text_position->CreatePreviousPageEndPosition(
4701 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4702 EXPECT_NE(nullptr, test_position);
4703 EXPECT_TRUE(test_position->IsTextPosition());
4704 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4705 EXPECT_EQ(19, test_position->text_offset());
4706
4707 test_position = text_position->CreatePreviousPageEndPosition(
4708 AXBoundaryBehavior::CrossBoundary);
4709 EXPECT_NE(nullptr, test_position);
4710 EXPECT_TRUE(test_position->IsTextPosition());
4711 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4712 EXPECT_EQ(19, test_position->text_offset());
4713
4714 test_position = test_position->CreatePreviousPageStartPosition(
4715 AXBoundaryBehavior::CrossBoundary);
4716 EXPECT_NE(nullptr, test_position);
4717 EXPECT_TRUE(test_position->IsTextPosition());
4718 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4719 EXPECT_EQ(0, test_position->text_offset());
4720
4721 test_position = test_position->CreatePreviousPageStartPosition(
4722 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4723 EXPECT_NE(nullptr, test_position);
4724 EXPECT_TRUE(test_position->IsTextPosition());
4725 EXPECT_EQ(page_1_text_data.id, test_position->anchor_id());
4726 EXPECT_EQ(0, test_position->text_offset());
4727
4728 test_position = test_position->CreatePreviousPageStartPosition(
4729 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4730 EXPECT_NE(nullptr, test_position);
4731 EXPECT_TRUE(test_position->IsTextPosition());
4732 EXPECT_EQ(page_1_text_data.id, test_position->anchor_id());
4733 EXPECT_EQ(0, test_position->text_offset());
4734
4735 // StopAtLastAnchorBoundary shouldn't move past the start of the document.
4736 test_position = test_position->CreatePreviousPageStartPosition(
4737 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4738 EXPECT_NE(nullptr, test_position);
4739 EXPECT_TRUE(test_position->IsTextPosition());
4740 EXPECT_EQ(page_1_text_data.id, test_position->anchor_id());
4741 EXPECT_EQ(0, test_position->text_offset());
4742
4743 test_position = test_position->CreatePreviousPageEndPosition(
4744 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4745 EXPECT_NE(nullptr, test_position);
4746 EXPECT_TRUE(test_position->IsTextPosition());
4747 EXPECT_EQ(page_1_text_data.id, test_position->anchor_id());
4748 EXPECT_EQ(0, test_position->text_offset());
4749
4750 // Moving before the start should return a null position.
4751 null_position = test_position->CreatePreviousPageStartPosition(
4752 AXBoundaryBehavior::CrossBoundary);
4753 EXPECT_NE(nullptr, null_position);
4754 EXPECT_TRUE(null_position->IsNullPosition());
4755
4756 null_position = test_position->CreatePreviousPageEndPosition(
4757 AXBoundaryBehavior::CrossBoundary);
4758 EXPECT_NE(nullptr, null_position);
4759 EXPECT_TRUE(null_position->IsNullPosition());
4760}

◆ TEST_F() [247/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtPageBoundaryWithTreePosition   
)

Definition at line 4762 of file ax_node_position_unittest.cc.

4762 {
4763 AXNodeData root_data, page_1_data, page_1_text_data, page_2_data,
4764 page_2_text_data, page_3_data, page_3_text_data;
4765 SetTree(CreateMultipageDocument(root_data, page_1_data, page_1_text_data,
4766 page_2_data, page_2_text_data, page_3_data,
4767 page_3_text_data));
4768
4769 // Test CreateNextPageStartPosition at the start of the document.
4770 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
4771 GetTreeID(), page_1_data.id, 0 /* child_index */);
4772 ASSERT_NE(nullptr, tree_position);
4773 ASSERT_TRUE(tree_position->IsTreePosition());
4774
4775 // StopIfAlreadyAtBoundary shouldn't move at all since it's at a boundary.
4776 TestPositionType test_position = tree_position->CreateNextPageStartPosition(
4777 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4778 EXPECT_NE(nullptr, test_position);
4779 EXPECT_TRUE(test_position->IsTreePosition());
4780 EXPECT_EQ(page_1_data.id, test_position->anchor_id());
4781 EXPECT_EQ(0, test_position->child_index());
4782
4783 test_position = tree_position->CreateNextPageStartPosition(
4784 AXBoundaryBehavior::CrossBoundary);
4785 EXPECT_NE(nullptr, test_position);
4786 EXPECT_TRUE(test_position->IsTreePosition());
4787 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4788 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
4789
4790 test_position = tree_position->CreateNextPageStartPosition(
4791 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4792 EXPECT_NE(nullptr, test_position);
4793 EXPECT_TRUE(test_position->IsTreePosition());
4794 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4795 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
4796
4797 // Test CreateNextPageEndPosition until the end of document is reached.
4798 test_position = tree_position->CreateNextPageEndPosition(
4799 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4800 EXPECT_NE(nullptr, test_position);
4801 EXPECT_TRUE(test_position->IsTreePosition());
4802 EXPECT_EQ(page_1_data.id, test_position->anchor_id());
4803 EXPECT_EQ(1, test_position->child_index());
4804
4805 test_position = test_position->CreateNextPageEndPosition(
4806 AXBoundaryBehavior::CrossBoundary);
4807 EXPECT_NE(nullptr, test_position);
4808 EXPECT_TRUE(test_position->IsTreePosition());
4809 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4810 EXPECT_EQ(0, test_position->child_index());
4811
4812 test_position = test_position->CreateNextPageEndPosition(
4813 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4814 EXPECT_NE(nullptr, test_position);
4815 EXPECT_TRUE(test_position->IsTreePosition());
4816 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4817 EXPECT_EQ(0, test_position->child_index());
4818
4819 // StopAtLastAnchorBoundary shouldn't move past the end of the document.
4820 test_position = test_position->CreateNextPageStartPosition(
4821 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4822 EXPECT_NE(nullptr, test_position);
4823 EXPECT_TRUE(test_position->IsTreePosition());
4824 EXPECT_EQ(page_3_text_data.id, test_position->anchor_id());
4825 EXPECT_EQ(0, test_position->child_index());
4826
4827 test_position = test_position->CreateNextPageEndPosition(
4828 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4829 EXPECT_NE(nullptr, test_position);
4830 EXPECT_TRUE(test_position->IsTreePosition());
4831 EXPECT_EQ(page_3_text_data.id, test_position->anchor_id());
4832 EXPECT_EQ(0, test_position->child_index());
4833
4834 // Moving forward past the end should return a null position.
4835 TestPositionType null_position = test_position->CreateNextPageStartPosition(
4836 AXBoundaryBehavior::CrossBoundary);
4837 EXPECT_NE(nullptr, null_position);
4838 EXPECT_TRUE(null_position->IsNullPosition());
4839
4840 null_position = test_position->CreateNextPageEndPosition(
4841 AXBoundaryBehavior::CrossBoundary);
4842 EXPECT_NE(nullptr, null_position);
4843 EXPECT_TRUE(null_position->IsNullPosition());
4844
4845 // Now move backward through the document.
4846 tree_position = test_position->CreatePreviousPageEndPosition(
4847 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4848 EXPECT_NE(nullptr, tree_position);
4849 EXPECT_TRUE(tree_position->IsTreePosition());
4850 EXPECT_EQ(page_3_text_data.id, tree_position->anchor_id());
4851 EXPECT_EQ(0, tree_position->child_index());
4852
4853 test_position = tree_position->CreatePreviousPageEndPosition(
4854 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4855 EXPECT_NE(nullptr, test_position);
4856 EXPECT_TRUE(test_position->IsTreePosition());
4857 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4858 EXPECT_EQ(0, test_position->child_index());
4859
4860 test_position = tree_position->CreatePreviousPageEndPosition(
4861 AXBoundaryBehavior::CrossBoundary);
4862 EXPECT_NE(nullptr, test_position);
4863 EXPECT_TRUE(test_position->IsTreePosition());
4864 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4865 EXPECT_EQ(0, test_position->child_index());
4866
4867 test_position = test_position->CreatePreviousPageStartPosition(
4868 AXBoundaryBehavior::CrossBoundary);
4869 EXPECT_NE(nullptr, test_position);
4870 EXPECT_TRUE(test_position->IsTreePosition());
4871 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4872 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
4873
4874 test_position = test_position->CreatePreviousPageStartPosition(
4875 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4876 EXPECT_NE(nullptr, test_position);
4877 EXPECT_TRUE(test_position->IsTreePosition());
4878 EXPECT_EQ(page_1_text_data.id, test_position->anchor_id());
4879 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
4880
4881 test_position = test_position->CreatePreviousPageStartPosition(
4882 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4883 EXPECT_NE(nullptr, test_position);
4884 EXPECT_TRUE(test_position->IsTreePosition());
4885 EXPECT_EQ(page_1_text_data.id, test_position->anchor_id());
4886 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
4887
4888 // StopAtLastAnchorBoundary shouldn't move past the start of the document.
4889 test_position = test_position->CreatePreviousPageStartPosition(
4890 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4891 EXPECT_NE(nullptr, test_position);
4892 EXPECT_TRUE(test_position->IsTreePosition());
4893 EXPECT_EQ(page_1_text_data.id, test_position->anchor_id());
4894 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
4895
4896 test_position = test_position->CreatePreviousPageEndPosition(
4897 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4898 EXPECT_NE(nullptr, test_position);
4899 EXPECT_TRUE(test_position->IsTreePosition());
4900 EXPECT_EQ(page_1_text_data.id, test_position->anchor_id());
4901 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
4902
4903 // Moving before the start should return a null position.
4904 null_position = test_position->CreatePreviousPageStartPosition(
4905 AXBoundaryBehavior::CrossBoundary);
4906 EXPECT_NE(nullptr, null_position);
4907 EXPECT_TRUE(null_position->IsNullPosition());
4908
4909 null_position = test_position->CreatePreviousPageEndPosition(
4910 AXBoundaryBehavior::CrossBoundary);
4911 EXPECT_NE(nullptr, null_position);
4912 EXPECT_TRUE(null_position->IsNullPosition());
4913}

◆ TEST_F() [248/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtPreviousFormatStartWithNullPosition   
)

Definition at line 4042 of file ax_node_position_unittest.cc.

4042 {
4043 TestPositionType null_position = AXNodePosition::CreateNullPosition();
4044 ASSERT_NE(nullptr, null_position);
4045 TestPositionType test_position =
4046 null_position->CreatePreviousFormatStartPosition(
4047 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4048 EXPECT_NE(nullptr, test_position);
4049 EXPECT_TRUE(test_position->IsNullPosition());
4050 test_position = null_position->CreatePreviousFormatStartPosition(
4051 AXBoundaryBehavior::CrossBoundary);
4052 EXPECT_NE(nullptr, test_position);
4053 EXPECT_TRUE(test_position->IsNullPosition());
4054 test_position = null_position->CreatePreviousFormatStartPosition(
4055 AXBoundaryBehavior::StopAtAnchorBoundary);
4056 EXPECT_NE(nullptr, test_position);
4057 EXPECT_TRUE(test_position->IsNullPosition());
4058}

◆ TEST_F() [249/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtPreviousFormatStartWithTextPosition   
)

Definition at line 4111 of file ax_node_position_unittest.cc.

4111 {
4113 GetTreeID(), inline_box1_.id, 2 /* text_offset */,
4115 ASSERT_NE(nullptr, text_position);
4116 ASSERT_TRUE(text_position->IsTextPosition());
4117
4118 TestPositionType test_position =
4119 text_position->CreatePreviousFormatStartPosition(
4120 AXBoundaryBehavior::CrossBoundary);
4121 EXPECT_NE(nullptr, test_position);
4122 EXPECT_TRUE(test_position->IsTextPosition());
4123 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
4124 EXPECT_EQ(0, test_position->text_offset());
4125 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
4126
4127 test_position = test_position->CreatePreviousFormatStartPosition(
4128 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4129 EXPECT_NE(nullptr, test_position);
4130 EXPECT_TRUE(test_position->IsTextPosition());
4131 EXPECT_EQ(check_box_.id, test_position->anchor_id());
4132 EXPECT_EQ(0, test_position->text_offset());
4133
4134 test_position = test_position->CreatePreviousFormatStartPosition(
4135 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4136 EXPECT_NE(nullptr, test_position);
4137 EXPECT_TRUE(test_position->IsTextPosition());
4138 EXPECT_EQ(button_.id, test_position->anchor_id());
4139 EXPECT_EQ(0, test_position->text_offset());
4140
4141 // StopIfAlreadyAtBoundary shouldn't move, since it's already at a boundary.
4142 test_position = test_position->CreatePreviousFormatStartPosition(
4143 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4144 EXPECT_NE(nullptr, test_position);
4145 EXPECT_TRUE(test_position->IsTextPosition());
4146 EXPECT_EQ(button_.id, test_position->anchor_id());
4147 EXPECT_EQ(0, test_position->text_offset());
4148
4149 // StopAtLastAnchorBoundary should stop at the start of the document while
4150 // CrossBoundary should return a null position when crossing it.
4151 test_position = test_position->CreatePreviousFormatStartPosition(
4152 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4153 EXPECT_NE(nullptr, test_position);
4154 EXPECT_TRUE(test_position->IsTextPosition());
4155 EXPECT_EQ(button_.id, test_position->anchor_id());
4156 EXPECT_EQ(0, test_position->text_offset());
4157
4158 test_position = test_position->CreatePreviousFormatStartPosition(
4159 AXBoundaryBehavior::CrossBoundary);
4160 EXPECT_NE(nullptr, test_position);
4161 EXPECT_TRUE(test_position->IsNullPosition());
4162}

◆ TEST_F() [250/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtPreviousFormatStartWithTreePosition   
)

Definition at line 4060 of file ax_node_position_unittest.cc.

4060 {
4061 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
4062 GetTreeID(), static_text1_.id, 1 /* child_index */);
4063 ASSERT_NE(nullptr, tree_position);
4064 ASSERT_TRUE(tree_position->IsTreePosition());
4065
4066 TestPositionType test_position =
4067 tree_position->CreatePreviousFormatStartPosition(
4068 AXBoundaryBehavior::CrossBoundary);
4069 EXPECT_NE(nullptr, test_position);
4070 EXPECT_TRUE(test_position->IsTreePosition());
4071 EXPECT_EQ(static_text1_.id, test_position->anchor_id());
4072 EXPECT_EQ(0, test_position->child_index());
4073
4074 test_position = test_position->CreatePreviousFormatStartPosition(
4075 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4076 EXPECT_NE(nullptr, test_position);
4077 EXPECT_TRUE(test_position->IsTreePosition());
4078 EXPECT_EQ(check_box_.id, test_position->anchor_id());
4079 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
4080
4081 test_position = test_position->CreatePreviousFormatStartPosition(
4082 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4083 EXPECT_NE(nullptr, test_position);
4084 EXPECT_TRUE(test_position->IsTreePosition());
4085 EXPECT_EQ(button_.id, test_position->anchor_id());
4086 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
4087
4088 // StopIfAlreadyAtBoundary shouldn't move, since it's already at a boundary.
4089 test_position = test_position->CreatePreviousFormatStartPosition(
4090 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4091 EXPECT_NE(nullptr, test_position);
4092 EXPECT_TRUE(test_position->IsTreePosition());
4093 EXPECT_EQ(button_.id, test_position->anchor_id());
4094 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
4095
4096 // StopAtLastAnchorBoundary should stop at the start of the document while
4097 // CrossBoundary should return a null position when crossing it.
4098 test_position = test_position->CreatePreviousFormatStartPosition(
4099 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4100 EXPECT_NE(nullptr, test_position);
4101 EXPECT_TRUE(test_position->IsTreePosition());
4102 EXPECT_EQ(button_.id, test_position->anchor_id());
4103 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
4104
4105 test_position = test_position->CreatePreviousFormatStartPosition(
4106 AXBoundaryBehavior::CrossBoundary);
4107 EXPECT_NE(nullptr, test_position);
4108 EXPECT_TRUE(test_position->IsNullPosition());
4109}

◆ TEST_F() [251/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtStartOfAnchorWithNullPosition   
)

Definition at line 3919 of file ax_node_position_unittest.cc.

3919 {
3920 TestPositionType null_position = AXNodePosition::CreateNullPosition();
3921 ASSERT_NE(nullptr, null_position);
3922 TestPositionType test_position =
3923 null_position->CreatePositionAtStartOfAnchor();
3924 EXPECT_NE(nullptr, test_position);
3925 EXPECT_TRUE(test_position->IsNullPosition());
3926}

◆ TEST_F() [252/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtStartOfAnchorWithTextPosition   
)

Definition at line 3959 of file ax_node_position_unittest.cc.

3959 {
3961 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
3963 ASSERT_NE(nullptr, text_position);
3964 ASSERT_TRUE(text_position->IsTextPosition());
3965 TestPositionType test_position =
3966 text_position->CreatePositionAtStartOfAnchor();
3967 ASSERT_NE(nullptr, test_position);
3968 EXPECT_TRUE(test_position->IsTextPosition());
3969 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3970 EXPECT_EQ(0, test_position->text_offset());
3971 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3972
3973 text_position = AXNodePosition::CreateTextPosition(
3974 GetTreeID(), inline_box1_.id, 1 /* text_offset */,
3976 ASSERT_NE(nullptr, text_position);
3977 ASSERT_TRUE(text_position->IsTextPosition());
3978 test_position = text_position->CreatePositionAtStartOfAnchor();
3979 EXPECT_NE(nullptr, test_position);
3980 EXPECT_TRUE(test_position->IsTextPosition());
3981 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3982 EXPECT_EQ(0, test_position->text_offset());
3983 // Affinity should have been reset to the default value.
3984 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3985}

◆ TEST_F() [253/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtStartOfAnchorWithTreePosition   
)

Definition at line 3928 of file ax_node_position_unittest.cc.

3928 {
3929 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
3930 GetTreeID(), root_.id, 0 /* child_index */);
3931 ASSERT_NE(nullptr, tree_position);
3932 TestPositionType test_position =
3933 tree_position->CreatePositionAtStartOfAnchor();
3934 EXPECT_NE(nullptr, test_position);
3935 EXPECT_TRUE(test_position->IsTreePosition());
3936 EXPECT_EQ(root_.id, test_position->anchor_id());
3937 EXPECT_EQ(0, test_position->child_index());
3938
3939 tree_position = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
3940 1 /* child_index */);
3941 ASSERT_NE(nullptr, tree_position);
3942 test_position = tree_position->CreatePositionAtStartOfAnchor();
3943 EXPECT_NE(nullptr, test_position);
3944 EXPECT_TRUE(test_position->IsTreePosition());
3945 EXPECT_EQ(root_.id, test_position->anchor_id());
3946 EXPECT_EQ(0, test_position->child_index());
3947
3948 // An "after text" position.
3949 tree_position = AXNodePosition::CreateTreePosition(
3950 GetTreeID(), inline_box1_.id, 0 /* child_index */);
3951 ASSERT_NE(nullptr, tree_position);
3952 test_position = tree_position->CreatePositionAtStartOfAnchor();
3953 EXPECT_NE(nullptr, test_position);
3954 EXPECT_TRUE(test_position->IsTreePosition());
3955 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3956 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3957}

◆ TEST_F() [254/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtStartOfDocumentWithNullPosition   
)

Definition at line 4940 of file ax_node_position_unittest.cc.

4940 {
4941 TestPositionType null_position = AXNodePosition::CreateNullPosition();
4942 ASSERT_NE(nullptr, null_position);
4943 TestPositionType test_position =
4944 null_position->CreatePositionAtStartOfDocument();
4945 EXPECT_NE(nullptr, test_position);
4946 EXPECT_TRUE(test_position->IsNullPosition());
4947}

◆ TEST_F() [255/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtStartOfDocumentWithTextPosition   
)

Definition at line 5044 of file ax_node_position_unittest.cc.

5044 {
5046 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
5048 ASSERT_NE(nullptr, text_position);
5049 TestPositionType test_position =
5050 text_position->CreatePositionAtStartOfDocument();
5051 EXPECT_NE(nullptr, test_position);
5052 EXPECT_EQ(root_.id, test_position->anchor_id());
5053
5054 text_position = AXNodePosition::CreateTextPosition(
5055 GetTreeID(), inline_box1_.id, 1 /* text_offset */,
5057 ASSERT_NE(nullptr, text_position);
5058 test_position = text_position->CreatePositionAtStartOfDocument();
5059 EXPECT_NE(nullptr, test_position);
5060 EXPECT_EQ(root_.id, test_position->anchor_id());
5061 // Affinity should have been reset to the default value.
5062 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
5063}

◆ TEST_F() [256/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtStartOfDocumentWithTreePosition   
)

Definition at line 5020 of file ax_node_position_unittest.cc.

5020 {
5021 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
5022 GetTreeID(), root_.id, 0 /* child_index */);
5023 ASSERT_NE(nullptr, tree_position);
5024 TestPositionType test_position =
5025 tree_position->CreatePositionAtStartOfDocument();
5026 EXPECT_NE(nullptr, test_position);
5027 EXPECT_EQ(root_.id, test_position->anchor_id());
5028
5029 tree_position = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
5030 1 /* child_index */);
5031 ASSERT_NE(nullptr, tree_position);
5032 test_position = tree_position->CreatePositionAtStartOfDocument();
5033 EXPECT_NE(nullptr, test_position);
5034 EXPECT_EQ(root_.id, test_position->anchor_id());
5035
5036 tree_position = AXNodePosition::CreateTreePosition(
5037 GetTreeID(), inline_box1_.id, 0 /* child_index */);
5038 ASSERT_NE(nullptr, tree_position);
5039 test_position = tree_position->CreatePositionAtStartOfDocument();
5040 EXPECT_NE(nullptr, test_position);
5041 EXPECT_EQ(root_.id, test_position->anchor_id());
5042}

◆ TEST_F() [257/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtTextBoundaryDocumentStartEndIsIgnored   
)

Definition at line 3747 of file ax_node_position_unittest.cc.

3747 {
3748 // +-root_data
3749 // +-static_text_data_1
3750 // | +-inline_box_data_1 IGNORED
3751 // +-static_text_data_2
3752 // | +-inline_box_data_2
3753 // +-static_text_data_3
3754 // | +-inline_box_data_3
3755 // +-static_text_data_4
3756 // +-inline_box_data_4 IGNORED
3757 constexpr AXNode::AXID ROOT_ID = 1;
3758 constexpr AXNode::AXID STATIC_TEXT1_ID = 2;
3759 constexpr AXNode::AXID STATIC_TEXT2_ID = 3;
3760 constexpr AXNode::AXID STATIC_TEXT3_ID = 4;
3761 constexpr AXNode::AXID STATIC_TEXT4_ID = 5;
3762 constexpr AXNode::AXID INLINE_BOX1_ID = 6;
3763 constexpr AXNode::AXID INLINE_BOX2_ID = 7;
3764 constexpr AXNode::AXID INLINE_BOX3_ID = 8;
3765 constexpr AXNode::AXID INLINE_BOX4_ID = 9;
3766
3767 AXNodeData root_data;
3768 root_data.id = ROOT_ID;
3770
3771 AXNodeData static_text_data_1;
3772 static_text_data_1.id = STATIC_TEXT1_ID;
3773 static_text_data_1.role = ax::mojom::Role::kStaticText;
3774 static_text_data_1.SetName("One");
3775
3776 AXNodeData inline_box_data_1;
3777 inline_box_data_1.id = INLINE_BOX1_ID;
3778 inline_box_data_1.role = ax::mojom::Role::kInlineTextBox;
3779 inline_box_data_1.SetName("One");
3780 inline_box_data_1.AddState(ax::mojom::State::kIgnored);
3781 inline_box_data_1.AddIntListAttribute(
3782 ax::mojom::IntListAttribute::kWordStarts, std::vector<int32_t>{0});
3784 std::vector<int32_t>{3});
3786 INLINE_BOX2_ID);
3787
3788 AXNodeData static_text_data_2;
3789 static_text_data_2.id = STATIC_TEXT2_ID;
3790 static_text_data_2.role = ax::mojom::Role::kStaticText;
3791 static_text_data_2.SetName("Two");
3792
3793 AXNodeData inline_box_data_2;
3794 inline_box_data_2.id = INLINE_BOX2_ID;
3795 inline_box_data_2.role = ax::mojom::Role::kInlineTextBox;
3796 inline_box_data_2.SetName("Two");
3797 inline_box_data_2.AddIntListAttribute(
3798 ax::mojom::IntListAttribute::kWordStarts, std::vector<int32_t>{0});
3799 inline_box_data_2.AddIntListAttribute(ax::mojom::IntListAttribute::kWordEnds,
3800 std::vector<int32_t>{3});
3801 inline_box_data_2.AddIntAttribute(ax::mojom::IntAttribute::kPreviousOnLineId,
3802 INLINE_BOX1_ID);
3803 inline_box_data_2.AddIntAttribute(ax::mojom::IntAttribute::kNextOnLineId,
3804 INLINE_BOX3_ID);
3805
3806 AXNodeData static_text_data_3;
3807 static_text_data_3.id = STATIC_TEXT3_ID;
3808 static_text_data_3.role = ax::mojom::Role::kStaticText;
3809 static_text_data_3.SetName("Three");
3810
3811 AXNodeData inline_box_data_3;
3812 inline_box_data_3.id = INLINE_BOX3_ID;
3813 inline_box_data_3.role = ax::mojom::Role::kInlineTextBox;
3814 inline_box_data_3.SetName("Three");
3815 inline_box_data_3.AddIntListAttribute(
3816 ax::mojom::IntListAttribute::kWordStarts, std::vector<int32_t>{0});
3817 inline_box_data_3.AddIntListAttribute(ax::mojom::IntListAttribute::kWordEnds,
3818 std::vector<int32_t>{5});
3819 inline_box_data_3.AddIntAttribute(ax::mojom::IntAttribute::kPreviousOnLineId,
3820 INLINE_BOX2_ID);
3821 inline_box_data_3.AddIntAttribute(ax::mojom::IntAttribute::kNextOnLineId,
3822 INLINE_BOX4_ID);
3823
3824 AXNodeData static_text_data_4;
3825 static_text_data_4.id = STATIC_TEXT4_ID;
3826 static_text_data_4.role = ax::mojom::Role::kStaticText;
3827 static_text_data_4.SetName("Four");
3828
3829 AXNodeData inline_box_data_4;
3830 inline_box_data_4.id = INLINE_BOX4_ID;
3831 inline_box_data_4.role = ax::mojom::Role::kInlineTextBox;
3832 inline_box_data_4.SetName("Four");
3833 inline_box_data_4.AddState(ax::mojom::State::kIgnored);
3834 inline_box_data_3.AddIntListAttribute(
3835 ax::mojom::IntListAttribute::kWordStarts, std::vector<int32_t>{0});
3836 inline_box_data_3.AddIntListAttribute(ax::mojom::IntListAttribute::kWordEnds,
3837 std::vector<int32_t>{4});
3838 inline_box_data_3.AddIntAttribute(ax::mojom::IntAttribute::kPreviousOnLineId,
3839 INLINE_BOX3_ID);
3840
3841 root_data.child_ids = {static_text_data_1.id, static_text_data_2.id,
3842 static_text_data_3.id, static_text_data_4.id};
3843 static_text_data_1.child_ids = {inline_box_data_1.id};
3844 static_text_data_2.child_ids = {inline_box_data_2.id};
3845 static_text_data_3.child_ids = {inline_box_data_3.id};
3846 static_text_data_4.child_ids = {inline_box_data_4.id};
3847
3848 SetTree(
3849 CreateAXTree({root_data, static_text_data_1, static_text_data_2,
3850 static_text_data_3, static_text_data_4, inline_box_data_1,
3851 inline_box_data_2, inline_box_data_3, inline_box_data_4}));
3852
3854 GetTreeID(), inline_box_data_2.id, 0 /* text_offset */,
3856 ASSERT_FALSE(text_position->IsIgnored());
3857 TestPositionType test_position = text_position->CreatePositionAtTextBoundary(
3859 AXBoundaryBehavior::StopAtLastAnchorBoundary);
3860 ASSERT_NE(nullptr, test_position);
3861 EXPECT_TRUE(test_position->IsTextPosition());
3862 EXPECT_EQ(inline_box_data_3.id, test_position->anchor_id());
3863 EXPECT_EQ(0, test_position->text_offset());
3864 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3865 test_position = text_position->CreatePositionAtTextBoundary(
3867 AXBoundaryBehavior::StopAtLastAnchorBoundary);
3868 ASSERT_NE(nullptr, test_position);
3869 EXPECT_TRUE(test_position->IsTextPosition());
3870 EXPECT_EQ(inline_box_data_2.id, test_position->anchor_id());
3871 EXPECT_EQ(0, test_position->text_offset());
3872 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3873
3874 text_position = AXNodePosition::CreateTextPosition(
3875 GetTreeID(), inline_box_data_3.id, 0 /* text_offset */,
3877 ASSERT_FALSE(text_position->IsIgnored());
3878 test_position = text_position->CreatePositionAtTextBoundary(
3880 AXBoundaryBehavior::StopAtLastAnchorBoundary);
3881 ASSERT_NE(nullptr, test_position);
3882 EXPECT_TRUE(test_position->IsTextPosition());
3883 EXPECT_EQ(inline_box_data_3.id, test_position->anchor_id());
3884 EXPECT_EQ(5, test_position->text_offset());
3885 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3886 test_position = text_position->CreatePositionAtTextBoundary(
3888 AXBoundaryBehavior::StopAtLastAnchorBoundary);
3889 ASSERT_NE(nullptr, test_position);
3890 EXPECT_TRUE(test_position->IsTextPosition());
3891 EXPECT_EQ(inline_box_data_2.id, test_position->anchor_id());
3892 EXPECT_EQ(0, test_position->text_offset());
3893 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3894}

◆ TEST_F() [258/325]

ui::TEST_F ( AXPositionTest  ,
CreatePreviousCharacterPosition   
)

Definition at line 6232 of file ax_node_position_unittest.cc.

6232 {
6234 GetTreeID(), inline_box2_.id, 5 /* text_offset */,
6236 ASSERT_NE(nullptr, text_position);
6237 ASSERT_TRUE(text_position->IsTextPosition());
6238
6239 TestPositionType test_position =
6240 text_position->CreatePreviousCharacterPosition(
6241 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6242 EXPECT_NE(nullptr, test_position);
6243 EXPECT_TRUE(test_position->IsTextPosition());
6244 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6245 EXPECT_EQ(5, test_position->text_offset());
6246 test_position = text_position->CreatePreviousCharacterPosition(
6247 AXBoundaryBehavior::CrossBoundary);
6248 EXPECT_NE(nullptr, test_position);
6249 EXPECT_TRUE(test_position->IsTextPosition());
6250 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6251 EXPECT_EQ(4, test_position->text_offset());
6252 test_position = text_position->CreatePreviousCharacterPosition(
6253 AXBoundaryBehavior::StopAtAnchorBoundary);
6254 EXPECT_NE(nullptr, test_position);
6255 EXPECT_TRUE(test_position->IsTextPosition());
6256 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6257 EXPECT_EQ(4, test_position->text_offset());
6258 test_position = text_position->CreatePreviousCharacterPosition(
6259 AXBoundaryBehavior::StopAtLastAnchorBoundary);
6260 EXPECT_NE(nullptr, test_position);
6261 EXPECT_TRUE(test_position->IsTextPosition());
6262 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6263 EXPECT_EQ(4, test_position->text_offset());
6264
6265 text_position = AXNodePosition::CreateTextPosition(
6266 GetTreeID(), inline_box2_.id, 1 /* text_offset */,
6268 ASSERT_NE(nullptr, text_position);
6269 ASSERT_TRUE(text_position->IsTextPosition());
6270
6271 test_position = text_position->CreatePreviousCharacterPosition(
6272 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6273 EXPECT_NE(nullptr, test_position);
6274 EXPECT_TRUE(test_position->IsTextPosition());
6275 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6276 EXPECT_EQ(1, test_position->text_offset());
6277 test_position = text_position->CreatePreviousCharacterPosition(
6278 AXBoundaryBehavior::CrossBoundary);
6279 EXPECT_NE(nullptr, test_position);
6280 EXPECT_TRUE(test_position->IsTextPosition());
6281 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6282 EXPECT_EQ(0, test_position->text_offset());
6283 test_position = text_position->CreatePreviousCharacterPosition(
6284 AXBoundaryBehavior::StopAtAnchorBoundary);
6285 EXPECT_NE(nullptr, test_position);
6286 EXPECT_TRUE(test_position->IsTextPosition());
6287 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6288 EXPECT_EQ(0, test_position->text_offset());
6289 test_position = text_position->CreatePreviousCharacterPosition(
6290 AXBoundaryBehavior::StopAtLastAnchorBoundary);
6291 EXPECT_NE(nullptr, test_position);
6292 EXPECT_TRUE(test_position->IsTextPosition());
6293 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6294 EXPECT_EQ(0, test_position->text_offset());
6295
6296 text_position = AXNodePosition::CreateTextPosition(
6297 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
6299 ASSERT_NE(nullptr, text_position);
6300 ASSERT_TRUE(text_position->IsTextPosition());
6301
6302 test_position = text_position->CreatePreviousCharacterPosition(
6303 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6304 EXPECT_NE(nullptr, test_position);
6305 EXPECT_TRUE(test_position->IsTextPosition());
6306 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6307 EXPECT_EQ(0, test_position->text_offset());
6308 test_position = text_position->CreatePreviousCharacterPosition(
6309 AXBoundaryBehavior::CrossBoundary);
6310 EXPECT_NE(nullptr, test_position);
6311 EXPECT_TRUE(test_position->IsTextPosition());
6312 EXPECT_EQ(line_break_.id, test_position->anchor_id());
6313 EXPECT_EQ(0, test_position->text_offset());
6314 test_position = text_position->CreatePreviousCharacterPosition(
6315 AXBoundaryBehavior::StopAtAnchorBoundary);
6316 EXPECT_NE(nullptr, test_position);
6317 EXPECT_TRUE(test_position->IsTextPosition());
6318 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6319 EXPECT_EQ(0, test_position->text_offset());
6320 test_position = text_position->CreatePreviousCharacterPosition(
6321 AXBoundaryBehavior::StopAtLastAnchorBoundary);
6322 EXPECT_NE(nullptr, test_position);
6323 EXPECT_TRUE(test_position->IsTextPosition());
6324 EXPECT_EQ(line_break_.id, test_position->anchor_id());
6325 EXPECT_EQ(0, test_position->text_offset());
6326
6327 text_position = AXNodePosition::CreateTextPosition(
6328 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
6330 ASSERT_NE(nullptr, text_position);
6331 ASSERT_TRUE(text_position->IsTextPosition());
6332
6333 test_position = text_position->CreatePreviousCharacterPosition(
6334 AXBoundaryBehavior::CrossBoundary);
6335 EXPECT_NE(nullptr, test_position);
6336 EXPECT_TRUE(test_position->IsNullPosition());
6337 test_position = text_position->CreatePreviousCharacterPosition(
6338 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6339 EXPECT_NE(nullptr, test_position);
6340 EXPECT_TRUE(test_position->IsTextPosition());
6341 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6342 EXPECT_EQ(0, test_position->text_offset());
6343 test_position = text_position->CreatePreviousCharacterPosition(
6344 AXBoundaryBehavior::StopAtAnchorBoundary);
6345 EXPECT_NE(nullptr, test_position);
6346 EXPECT_TRUE(test_position->IsTextPosition());
6347 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6348 EXPECT_EQ(0, test_position->text_offset());
6349 test_position = text_position->CreatePreviousCharacterPosition(
6350 AXBoundaryBehavior::StopAtLastAnchorBoundary);
6351 EXPECT_NE(nullptr, test_position);
6352 EXPECT_TRUE(test_position->IsTextPosition());
6353 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6354 EXPECT_EQ(0, test_position->text_offset());
6355
6356 text_position = AXNodePosition::CreateTextPosition(
6357 GetTreeID(), check_box_.id, 0 /* text_offset */,
6359 ASSERT_NE(nullptr, text_position);
6360 ASSERT_TRUE(text_position->IsTextPosition());
6361
6362 test_position = text_position->CreatePreviousCharacterPosition(
6363 AXBoundaryBehavior::CrossBoundary);
6364 EXPECT_NE(nullptr, test_position);
6365 EXPECT_TRUE(test_position->IsNullPosition());
6366 test_position = text_position->CreatePreviousCharacterPosition(
6367 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6368 EXPECT_NE(nullptr, test_position);
6369 EXPECT_TRUE(test_position->IsTextPosition());
6370 EXPECT_EQ(check_box_.id, test_position->anchor_id());
6371 EXPECT_EQ(0, test_position->text_offset());
6372 test_position = text_position->CreatePreviousCharacterPosition(
6373 AXBoundaryBehavior::StopAtAnchorBoundary);
6374 EXPECT_NE(nullptr, test_position);
6375 EXPECT_TRUE(test_position->IsTextPosition());
6376 EXPECT_EQ(check_box_.id, test_position->anchor_id());
6377 EXPECT_EQ(0, test_position->text_offset());
6378 test_position = text_position->CreatePreviousCharacterPosition(
6379 AXBoundaryBehavior::StopAtLastAnchorBoundary);
6380 EXPECT_NE(nullptr, test_position);
6381 EXPECT_TRUE(test_position->IsTextPosition());
6382 EXPECT_EQ(check_box_.id, test_position->anchor_id());
6383 EXPECT_EQ(0, test_position->text_offset());
6384
6385 text_position = AXNodePosition::CreateTextPosition(
6386 GetTreeID(), text_field_.id, 1 /* text_offset */,
6388 ASSERT_NE(nullptr, text_position);
6389 ASSERT_TRUE(text_position->IsTextPosition());
6390
6391 test_position = text_position->CreatePreviousCharacterPosition(
6392 AXBoundaryBehavior::CrossBoundary);
6393 EXPECT_NE(nullptr, test_position);
6394 EXPECT_TRUE(test_position->IsTextPosition());
6395 EXPECT_EQ(text_field_.id, test_position->anchor_id());
6396 EXPECT_EQ(0, test_position->text_offset());
6397 // Affinity should have been reset to downstream.
6398 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
6399}

◆ TEST_F() [259/325]

ui::TEST_F ( AXPositionTest  ,
CreatePreviousCharacterPositionAtGraphemeBoundary   
)

Definition at line 6480 of file ax_node_position_unittest.cc.

6480 {
6481#if true
6482 GTEST_SKIP()
6483 << "Skipping, current accessibility library cannot handle grapheme";
6484#else
6485 std::vector<int> text_offsets;
6486 SetTree(CreateMultilingualDocument(&text_offsets));
6487
6488 TestPositionType test_position =
6489 AXNodePosition::CreateTextPosition(GetTreeID(), GetTree()->root()->id(),
6490 text_offsets.back() /* text_offset */,
6492 ASSERT_NE(nullptr, test_position);
6493 ASSERT_TRUE(test_position->IsTextPosition());
6494
6495 for (auto iter = (text_offsets.rbegin() + 1); iter != text_offsets.rend();
6496 ++iter) {
6497 const int text_offset = *iter;
6498 test_position = test_position->CreatePreviousCharacterPosition(
6499 AXBoundaryBehavior::CrossBoundary);
6500 ASSERT_NE(nullptr, test_position);
6501 EXPECT_TRUE(test_position->IsTextPosition());
6502
6503 testing::Message message;
6504 message << "Expecting character boundary at " << text_offset << " in\n"
6505 << *test_position;
6506 SCOPED_TRACE(message);
6507
6508 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
6509 EXPECT_EQ(text_offset, test_position->text_offset());
6510 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
6511 }
6512
6513 test_position = AXNodePosition::CreateTextPosition(
6514 GetTreeID(), GetTree()->root()->id(), 3 /* text_offset */,
6516 test_position = test_position->CreatePreviousCharacterPosition(
6517 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6518 ASSERT_NE(nullptr, test_position);
6519 EXPECT_TRUE(test_position->IsTextPosition());
6520 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
6521 EXPECT_EQ(3, test_position->text_offset());
6522 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
6523
6524 test_position = AXNodePosition::CreateTextPosition(
6525 GetTreeID(), GetTree()->root()->id(), 4 /* text_offset */,
6527 test_position = test_position->CreatePreviousCharacterPosition(
6528 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6529 ASSERT_NE(nullptr, test_position);
6530 EXPECT_TRUE(test_position->IsTextPosition());
6531 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
6532 EXPECT_EQ(3, test_position->text_offset());
6533 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
6534
6535 test_position = AXNodePosition::CreateTextPosition(
6536 GetTreeID(), GetTree()->root()->id(), 9 /* text_offset */,
6538 test_position = test_position->CreatePreviousCharacterPosition(
6539 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6540 ASSERT_NE(nullptr, test_position);
6541 EXPECT_TRUE(test_position->IsTextPosition());
6542 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
6543 EXPECT_EQ(9, test_position->text_offset());
6544 EXPECT_EQ(ax::mojom::TextAffinity::kUpstream, test_position->affinity());
6545
6546 test_position = AXNodePosition::CreateTextPosition(
6547 GetTreeID(), GetTree()->root()->id(), 10 /* text_offset */,
6549 test_position = test_position->CreatePreviousCharacterPosition(
6550 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6551 ASSERT_NE(nullptr, test_position);
6552 EXPECT_TRUE(test_position->IsTextPosition());
6553 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
6554 EXPECT_EQ(9, test_position->text_offset());
6555 // Affinity should have been reset to downstream because there was a move.
6556 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
6557#endif // true
6558}

◆ TEST_F() [260/325]

ui::TEST_F ( AXPositionTest  ,
CreatePreviousLeafTextPosition   
)

Definition at line 5361 of file ax_node_position_unittest.cc.

5361 {
5363 GetTreeID(), inline_box2_.id, 5 /* text_offset */,
5365 ASSERT_NE(nullptr, text_position);
5366 ASSERT_TRUE(text_position->IsTextPosition());
5367 TestPositionType test_position =
5368 text_position->CreatePreviousLeafTextPosition();
5369 EXPECT_NE(nullptr, test_position);
5370 EXPECT_TRUE(test_position->IsTextPosition());
5371 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5372 EXPECT_EQ(line_break_.id, test_position->anchor_id());
5373 EXPECT_EQ(0, test_position->text_offset());
5374
5375 // Create a "before text" tree position on the second line of the text box.
5376 TestPositionType before_text_position = AXNodePosition::CreateTreePosition(
5377 GetTreeID(), inline_box2_.id, AXNodePosition::BEFORE_TEXT);
5378 ASSERT_NE(nullptr, before_text_position);
5379 test_position = before_text_position->CreatePreviousLeafTextPosition();
5380 EXPECT_NE(nullptr, test_position);
5381 EXPECT_TRUE(test_position->IsTextPosition());
5382 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5383 EXPECT_EQ(line_break_.id, test_position->anchor_id());
5384 EXPECT_EQ(0, test_position->text_offset());
5385
5386 test_position = test_position->CreatePreviousLeafTextPosition();
5387 EXPECT_NE(nullptr, test_position);
5388 EXPECT_TRUE(test_position->IsTextPosition());
5389 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5390 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
5391 EXPECT_EQ(0, test_position->text_offset());
5392
5393 test_position = test_position->CreatePreviousLeafTextPosition();
5394 EXPECT_NE(nullptr, test_position);
5395 EXPECT_TRUE(test_position->IsTextPosition());
5396 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5397 EXPECT_EQ(check_box_.id, test_position->anchor_id());
5398 EXPECT_EQ(0, test_position->text_offset());
5399
5400 test_position = test_position->CreatePreviousLeafTextPosition();
5401 EXPECT_NE(nullptr, test_position);
5402 EXPECT_TRUE(test_position->IsTextPosition());
5403 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5404 EXPECT_EQ(button_.id, test_position->anchor_id());
5405 EXPECT_EQ(0, test_position->text_offset());
5406
5407 test_position = test_position->CreatePreviousLeafTextPosition();
5408 EXPECT_NE(nullptr, test_position);
5409 EXPECT_TRUE(test_position->IsNullPosition());
5410
5411 TestPositionType text_field_position = AXNodePosition::CreateTreePosition(
5412 GetTreeID(), text_field_.id, 2 /* child_index */);
5413 ASSERT_NE(nullptr, text_field_position);
5414 test_position = text_field_position->CreatePreviousLeafTextPosition();
5415 EXPECT_NE(nullptr, test_position);
5416 EXPECT_TRUE(test_position->IsTextPosition());
5417 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5418 EXPECT_EQ(check_box_.id, test_position->anchor_id());
5419 EXPECT_EQ(0, test_position->text_offset());
5420
5421 // The text offset on the root points to the text coming from inside the check
5422 // box.
5424 GetTreeID(), check_box_.id, 0 /* text_offset */,
5426 ASSERT_NE(nullptr, check_box_position);
5427 ASSERT_TRUE(check_box_position->IsTextPosition());
5428 test_position = check_box_position->CreatePreviousLeafTextPosition();
5429 EXPECT_NE(nullptr, test_position);
5430 EXPECT_TRUE(test_position->IsTextPosition());
5431 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5432 EXPECT_EQ(button_.id, test_position->anchor_id());
5433 EXPECT_EQ(0, test_position->text_offset());
5434
5435 // The root text position should resolve to its leaf text position,
5436 // maintaining its text_offset
5438 GetTreeID(), root_.id, 10 /* text_offset */,
5440 ASSERT_NE(nullptr, root_position2);
5441 ASSERT_TRUE(root_position2->IsTextPosition());
5442 test_position = root_position2->CreatePreviousLeafTextPosition();
5443 EXPECT_NE(nullptr, test_position);
5444 EXPECT_TRUE(test_position->IsTextPosition());
5445 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5446 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5447 EXPECT_EQ(3, test_position->text_offset());
5448}

◆ TEST_F() [261/325]

ui::TEST_F ( AXPositionTest  ,
CreatePreviousLeafTreePosition   
)

Definition at line 5509 of file ax_node_position_unittest.cc.

5509 {
5510 TestPositionType inline_box2_position = AXNodePosition::CreateTreePosition(
5511 GetTreeID(), inline_box2_.id, AXNodePosition::BEFORE_TEXT);
5512 ASSERT_TRUE(inline_box2_position->IsTreePosition());
5513
5514 TestPositionType line_break_position = AXNodePosition::CreateTreePosition(
5515 GetTreeID(), line_break_.id, AXNodePosition::BEFORE_TEXT);
5516 TestPositionType inline_box1_position = AXNodePosition::CreateTreePosition(
5517 GetTreeID(), inline_box1_.id, AXNodePosition::BEFORE_TEXT);
5518 TestPositionType checkbox_position = AXNodePosition::CreateTreePosition(
5519 GetTreeID(), check_box_.id, AXNodePosition::BEFORE_TEXT);
5520 TestPositionType button_position = AXNodePosition::CreateTreePosition(
5521 GetTreeID(), button_.id, AXNodePosition::BEFORE_TEXT);
5522
5523 TestPositionType test_position =
5524 inline_box2_position->CreatePreviousLeafTreePosition();
5525 EXPECT_TRUE(test_position->IsTreePosition());
5526 EXPECT_EQ(*test_position, *line_break_position);
5527
5528 test_position = test_position->CreatePreviousLeafTreePosition();
5529 EXPECT_TRUE(test_position->IsTreePosition());
5530 EXPECT_EQ(*test_position, *inline_box1_position);
5531
5532 test_position = test_position->CreatePreviousLeafTreePosition();
5533 EXPECT_TRUE(test_position->IsTreePosition());
5534 EXPECT_EQ(*test_position, *checkbox_position);
5535
5536 test_position = test_position->CreatePreviousLeafTreePosition();
5537 EXPECT_TRUE(test_position->IsTreePosition());
5538 EXPECT_EQ(*test_position, *button_position);
5539
5540 test_position = test_position->CreatePreviousLeafTreePosition();
5541 EXPECT_TRUE(test_position->IsNullPosition());
5542
5543 TestPositionType inline_box2_text_position =
5544 AXNodePosition::CreateTextPosition(GetTreeID(), inline_box2_.id,
5545 2 /* text_offset */,
5547 EXPECT_TRUE(inline_box2_text_position->IsTextPosition());
5548
5549 test_position = inline_box2_text_position->CreatePreviousLeafTreePosition();
5550 EXPECT_TRUE(test_position->IsTreePosition());
5551 EXPECT_EQ(*test_position, *line_break_position);
5552}

◆ TEST_F() [262/325]

ui::TEST_F ( AXPositionTest  ,
CreatePreviousWordPositionInList   
)

Definition at line 7335 of file ax_node_position_unittest.cc.

7335 {
7336 // This test updates the tree structure to test a specific edge case -
7337 // previous word navigation inside a list with AXListMarkers nodes.
7338 // ++1 kRootWebArea
7339 // ++++2 kList
7340 // ++++++3 kListItem
7341 // ++++++++4 kListMarker
7342 // ++++++++++5 kStaticText
7343 // ++++++++++++6 kInlineTextBox "1. "
7344 // ++++++++7 kStaticText
7345 // ++++++++++8 kInlineTextBox "first item"
7346 // ++++++9 kListItem
7347 // ++++++++10 kListMarker
7348 // +++++++++++11 kStaticText
7349 // ++++++++++++++12 kInlineTextBox "2. "
7350 // ++++++++13 kStaticText
7351 // ++++++++++14 kInlineTextBox "second item"
7353 AXNodeData list;
7354 AXNodeData list_item1;
7355 AXNodeData list_item2;
7356 AXNodeData list_marker1;
7357 AXNodeData list_marker2;
7358 AXNodeData inline_box1;
7359 AXNodeData inline_box2;
7360 AXNodeData inline_box3;
7361 AXNodeData inline_box4;
7362 AXNodeData static_text1;
7363 AXNodeData static_text2;
7364 AXNodeData static_text3;
7365 AXNodeData static_text4;
7366
7367 root.id = 1;
7368 list.id = 2;
7369 list_item1.id = 3;
7370 list_marker1.id = 4;
7371 static_text1.id = 5;
7372 inline_box1.id = 6;
7373 static_text2.id = 7;
7374 inline_box2.id = 8;
7375 list_item2.id = 9;
7376 list_marker2.id = 10;
7377 static_text3.id = 11;
7378 inline_box3.id = 12;
7379 static_text4.id = 13;
7380 inline_box4.id = 14;
7381
7383 root.child_ids = {list.id};
7384
7386 list.child_ids = {list_item1.id, list_item2.id};
7387
7388 list_item1.role = ax::mojom::Role::kListItem;
7389 list_item1.child_ids = {list_marker1.id, static_text2.id};
7391 true);
7392
7393 list_marker1.role = ax::mojom::Role::kListMarker;
7394 list_marker1.child_ids = {static_text1.id};
7395
7396 static_text1.role = ax::mojom::Role::kStaticText;
7397 static_text1.SetName("1. ");
7398 static_text1.child_ids = {inline_box1.id};
7399
7401 inline_box1.SetName("1. ");
7403 std::vector<int32_t>{0});
7405 std::vector<int32_t>{3});
7406
7407 static_text2.role = ax::mojom::Role::kStaticText;
7408 static_text2.SetName("first item");
7409 static_text2.child_ids = {inline_box2.id};
7410
7412 inline_box2.SetName("first item");
7414 std::vector<int32_t>{0, 6});
7416 std::vector<int32_t>{5});
7417
7418 list_item2.role = ax::mojom::Role::kListItem;
7419 list_item2.child_ids = {list_marker2.id, static_text4.id};
7421 true);
7422
7423 list_marker2.role = ax::mojom::Role::kListMarker;
7424 list_marker2.child_ids = {static_text3.id};
7425
7426 static_text3.role = ax::mojom::Role::kStaticText;
7427 static_text3.SetName("2. ");
7428 static_text3.child_ids = {inline_box3.id};
7429
7431 inline_box3.SetName("2. ");
7433 std::vector<int32_t>{0});
7435 std::vector<int32_t>{3});
7436
7437 static_text4.role = ax::mojom::Role::kStaticText;
7438 static_text4.SetName("second item");
7439 static_text4.child_ids = {inline_box4.id};
7440
7442 inline_box4.SetName("second item");
7444 std::vector<int32_t>{0, 7});
7446 std::vector<int32_t>{6});
7447
7448 SetTree(CreateAXTree({root, list, list_item1, list_marker1, static_text1,
7449 inline_box1, static_text2, inline_box2, list_item2,
7450 list_marker2, static_text3, inline_box3, static_text4,
7451 inline_box4}));
7452
7454 GetTreeID(), inline_box4.id, 11 /* text_offset */,
7456 ASSERT_NE(nullptr, text_position);
7457 ASSERT_TRUE(text_position->IsTextPosition());
7458 ASSERT_EQ(inline_box4.id, text_position->anchor_id());
7459 ASSERT_EQ(11, text_position->text_offset());
7460
7461 // "1. first item\n2. second <i>tem"
7462 text_position = text_position->CreatePreviousWordStartPosition(
7463 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7464 ASSERT_NE(nullptr, text_position);
7465 ASSERT_TRUE(text_position->IsTextPosition());
7466 ASSERT_EQ(inline_box4.id, text_position->anchor_id());
7467 ASSERT_EQ(7, text_position->text_offset());
7468
7469 // "1. first item\n2. <s>econd item"
7470 text_position = text_position->CreatePreviousWordStartPosition(
7471 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7472 ASSERT_NE(nullptr, text_position);
7473 ASSERT_TRUE(text_position->IsTextPosition());
7474 ASSERT_EQ(inline_box4.id, text_position->anchor_id());
7475 ASSERT_EQ(0, text_position->text_offset());
7476
7477 // "1. first item\n<2>. second item"
7478 text_position = text_position->CreatePreviousWordStartPosition(
7479 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7480 ASSERT_NE(nullptr, text_position);
7481 ASSERT_TRUE(text_position->IsTextPosition());
7482 ASSERT_EQ(inline_box3.id, text_position->anchor_id());
7483 ASSERT_EQ(0, text_position->text_offset());
7484
7485 // "1. first <i>tem\n2. <s>econd item"
7486 text_position = text_position->CreatePreviousWordStartPosition(
7487 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7488 ASSERT_NE(nullptr, text_position);
7489 ASSERT_TRUE(text_position->IsTextPosition());
7490 ASSERT_EQ(inline_box2.id, text_position->anchor_id());
7491 ASSERT_EQ(6, text_position->text_offset());
7492
7493 // "1. <f>irst item\n2. second item"
7494 text_position = text_position->CreatePreviousWordStartPosition(
7495 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7496 ASSERT_NE(nullptr, text_position);
7497 ASSERT_TRUE(text_position->IsTextPosition());
7498 ASSERT_EQ(inline_box2.id, text_position->anchor_id());
7499 ASSERT_EQ(0, text_position->text_offset());
7500
7501 // "<1>. first item\n2. second item"
7502 text_position = text_position->CreatePreviousWordStartPosition(
7503 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7504 ASSERT_NE(nullptr, text_position);
7505 ASSERT_TRUE(text_position->IsTextPosition());
7506 ASSERT_EQ(inline_box1.id, text_position->anchor_id());
7507 ASSERT_EQ(0, text_position->text_offset());
7508}

◆ TEST_F() [263/325]

ui::TEST_F ( AXPositionTest  ,
EmptyObjectReplacedByCharacterTextNavigation   
)

Definition at line 7510 of file ax_node_position_unittest.cc.

7510 {
7511 g_ax_embedded_object_behavior = AXEmbeddedObjectBehavior::kExposeCharacter;
7512
7513 // ++1 kRootWebArea
7514 // ++++2 kStaticText
7515 // ++++++3 kInlineTextBox
7516 // ++++4 kTextField
7517 // ++++++5 kGenericContainer
7518 // ++++6 kStaticText
7519 // ++++++7 kInlineTextBox
7520 // ++++8 kHeading
7521 // ++++++9 kStaticText
7522 // ++++++++10 kInlineTextBox
7523 // ++++11 kGenericContainer ignored
7524 // ++++12 kGenericContainer
7525 // ++++13 kStaticText
7526 // ++++14 kButton
7527 // ++++++15 kGenericContainer ignored
7528 AXNodeData root_1;
7529 AXNodeData static_text_2;
7530 AXNodeData inline_box_3;
7531 AXNodeData text_field_4;
7532 AXNodeData generic_container_5;
7533 AXNodeData static_text_6;
7534 AXNodeData inline_box_7;
7535 AXNodeData heading_8;
7536 AXNodeData static_text_9;
7537 AXNodeData inline_box_10;
7538 AXNodeData generic_container_11;
7539 AXNodeData generic_container_12;
7540 AXNodeData static_text_13;
7541 AXNodeData button_14;
7542 AXNodeData generic_container_15;
7543
7544 root_1.id = 1;
7545 static_text_2.id = 2;
7546 inline_box_3.id = 3;
7547 text_field_4.id = 4;
7548 generic_container_5.id = 5;
7549 static_text_6.id = 6;
7550 inline_box_7.id = 7;
7551 heading_8.id = 8;
7552 static_text_9.id = 9;
7553 inline_box_10.id = 10;
7554 generic_container_11.id = 11;
7555 generic_container_12.id = 12;
7556 static_text_13.id = 13;
7557 button_14.id = 14;
7558 generic_container_15.id = 15;
7559
7561 root_1.child_ids = {static_text_2.id, text_field_4.id,
7562 static_text_6.id, heading_8.id,
7563 generic_container_11.id, generic_container_12.id,
7564 static_text_13.id, button_14.id};
7565
7566 static_text_2.role = ax::mojom::Role::kStaticText;
7567 static_text_2.SetName("Hello ");
7568 static_text_2.child_ids = {inline_box_3.id};
7569
7571 inline_box_3.SetName("Hello ");
7573 std::vector<int32_t>{0});
7575 std::vector<int32_t>{6});
7576
7577 text_field_4.role = ax::mojom::Role::kGroup;
7578 text_field_4.child_ids = {generic_container_5.id};
7579
7580 generic_container_5.role = ax::mojom::Role::kGenericContainer;
7581
7582 static_text_6.role = ax::mojom::Role::kStaticText;
7583 static_text_6.SetName(" world");
7584 static_text_6.child_ids = {inline_box_7.id};
7585
7587 inline_box_7.SetName(" world");
7589 std::vector<int32_t>{1});
7591 std::vector<int32_t>{6});
7592
7593 heading_8.role = ax::mojom::Role::kHeading;
7594 heading_8.child_ids = {static_text_9.id};
7595
7596 static_text_9.role = ax::mojom::Role::kStaticText;
7597 static_text_9.child_ids = {inline_box_10.id};
7598 static_text_9.SetName("3.14");
7599
7600 inline_box_10.role = ax::mojom::Role::kInlineTextBox;
7601 inline_box_10.SetName("3.14");
7602
7603 generic_container_11.role = ax::mojom::Role::kGenericContainer;
7604 generic_container_11.AddBoolAttribute(
7606 generic_container_11.AddState(ax::mojom::State::kIgnored);
7607
7608 generic_container_12.role = ax::mojom::Role::kGenericContainer;
7609 generic_container_12.AddBoolAttribute(
7611
7612 static_text_13.role = ax::mojom::Role::kStaticText;
7613 static_text_13.SetName("hey");
7614
7615 button_14.role = ax::mojom::Role::kButton;
7616 button_14.child_ids = {generic_container_15.id};
7617
7618 generic_container_15.role = ax::mojom::Role::kGenericContainer;
7619 generic_container_15.AddState(ax::mojom::State::kIgnored);
7620
7621 SetTree(CreateAXTree({root_1, static_text_2, inline_box_3, text_field_4,
7622 generic_container_5, static_text_6, inline_box_7,
7623 heading_8, static_text_9, inline_box_10,
7624 generic_container_11, generic_container_12,
7625 static_text_13, button_14, generic_container_15}));
7626
7627 // CreateNextWordStartPosition tests.
7629 GetTreeID(), inline_box_3.id, 0 /* child_index_or_text_offset */,
7631
7632 TestPositionType result_position =
7633 position->CreateNextWordStartPosition(AXBoundaryBehavior::CrossBoundary);
7634 std::string expectations =
7635 "TextPosition anchor_id=5 text_offset=0 affinity=downstream "
7636 "annotated_text=<\xEF\xBF\xBC>";
7637 ASSERT_EQ(result_position->ToString(), expectations);
7638
7639 position = std::move(result_position);
7640 result_position =
7641 position->CreateNextWordStartPosition(AXBoundaryBehavior::CrossBoundary);
7642 expectations =
7643 "TextPosition anchor_id=7 text_offset=1 affinity=downstream "
7644 "annotated_text= <w>orld";
7645 ASSERT_EQ(result_position->ToString(), expectations);
7646
7647 // CreatePreviousWordStartPosition tests.
7648 position = std::move(result_position);
7649 result_position = position->CreatePreviousWordStartPosition(
7650 AXBoundaryBehavior::CrossBoundary);
7651 expectations =
7652 "TextPosition anchor_id=5 text_offset=0 affinity=downstream "
7653 "annotated_text=<\xEF\xBF\xBC>";
7654 ASSERT_EQ(result_position->ToString(), expectations);
7655
7656 position = std::move(result_position);
7657 result_position = position->CreatePreviousWordStartPosition(
7658 AXBoundaryBehavior::CrossBoundary);
7659 expectations =
7660 "TextPosition anchor_id=3 text_offset=0 affinity=downstream "
7661 "annotated_text=<H>ello ";
7662 ASSERT_EQ(result_position->ToString(), expectations);
7663
7664 // CreateNextWordEndPosition tests.
7665 position = std::move(result_position);
7666 result_position =
7667 position->CreateNextWordEndPosition(AXBoundaryBehavior::CrossBoundary);
7668 expectations =
7669 "TextPosition anchor_id=3 text_offset=6 affinity=downstream "
7670 "annotated_text=Hello <>";
7671 ASSERT_EQ(result_position->ToString(), expectations);
7672
7673 position = std::move(result_position);
7674 result_position =
7675 position->CreateNextWordEndPosition(AXBoundaryBehavior::CrossBoundary);
7676 expectations =
7677 "TextPosition anchor_id=5 text_offset=1 affinity=downstream "
7678 "annotated_text=\xEF\xBF\xBC<>";
7679 ASSERT_EQ(result_position->ToString(), expectations);
7680
7681 position = std::move(result_position);
7682 result_position =
7683 position->CreateNextWordEndPosition(AXBoundaryBehavior::CrossBoundary);
7684 expectations =
7685 "TextPosition anchor_id=7 text_offset=6 affinity=downstream "
7686 "annotated_text= world<>";
7687 ASSERT_EQ(result_position->ToString(), expectations);
7688
7689 // CreatePreviousWordEndPosition tests.
7690 position = std::move(result_position);
7691 result_position = position->CreatePreviousWordEndPosition(
7692 AXBoundaryBehavior::CrossBoundary);
7693 expectations =
7694 "TextPosition anchor_id=5 text_offset=1 affinity=downstream "
7695 "annotated_text=\xEF\xBF\xBC<>";
7696 ASSERT_EQ(result_position->ToString(), expectations);
7697
7698 position = std::move(result_position);
7699 result_position = position->CreatePreviousWordEndPosition(
7700 AXBoundaryBehavior::CrossBoundary);
7701 expectations =
7702 "TextPosition anchor_id=3 text_offset=6 affinity=downstream "
7703 "annotated_text=Hello <>";
7704 ASSERT_EQ(result_position->ToString(), expectations);
7705
7706 // GetText() with embedded object replacement character test.
7708 GetTreeID(), generic_container_5.id, 0 /* text_offset */,
7710
7711 std::u16string expected_text;
7712 expected_text += AXNodePosition::kEmbeddedCharacter;
7713 ASSERT_EQ(expected_text, position->GetText());
7714
7715 // GetText() on a node parent of text nodes and an embedded object replacement
7716 // character.
7718 GetTreeID(), root_1.id, 0 /* text_offset */,
7720
7721 expected_text =
7722 std::u16string(u"Hello ") + AXNodePosition::kEmbeddedCharacter +
7723 std::u16string(u" world3.14") + AXNodePosition::kEmbeddedCharacter +
7724 std::u16string(u"hey") + AXNodePosition::kEmbeddedCharacter;
7725 ASSERT_EQ(expected_text, position->GetText());
7726
7727 // MaxTextOffset() with an embedded object replacement character.
7729 GetTreeID(), generic_container_5.id, 0 /* text_offset */,
7731
7732 ASSERT_EQ(1, position->MaxTextOffset());
7733
7734 // Parent positions created from a position inside a node represented by an
7735 // embedded object replacement character.
7736 position = position->CreateParentPosition();
7737 expectations =
7738 "TextPosition anchor_id=4 text_offset=0 affinity=downstream "
7739 "annotated_text=<\xEF\xBF\xBC>";
7740 ASSERT_EQ(position->ToString(), expectations);
7741 ASSERT_EQ(1, position->MaxTextOffset());
7742
7743 position = position->CreateParentPosition();
7744 expectations =
7745 "TextPosition anchor_id=1 text_offset=6 affinity=downstream "
7746 "annotated_text=Hello <\xEF\xBF\xBC> "
7747 "world3.14\xEF\xBF\xBChey\xEF\xBF\xBC";
7748 ASSERT_EQ(position->ToString(), expectations);
7749 ASSERT_EQ(22, position->MaxTextOffset());
7750
7751 // MaxTextOffset() on a node parent of text nodes and an embedded object
7752 // replacement character.
7754 GetTreeID(), root_1.id, 0 /* text_offset */,
7756 ASSERT_EQ(22, position->MaxTextOffset());
7757
7758 // The following is to test a specific edge case with heading navigation,
7759 // occurring in AXPosition::CreatePreviousFormatStartPosition.
7760 //
7761 // When the position is at the beginning of an unignored empty object,
7762 // preceded by an ignored empty object itself preceded by an heading node, the
7763 // previous format start position should stay on this unignored empty object.
7764 // It shouldn't move to the beginning of the heading.
7766 GetTreeID(), generic_container_12.id, 0 /* text_offset */,
7768 ASSERT_NE(nullptr, text_position);
7769
7770 text_position = text_position->CreatePreviousFormatStartPosition(
7771 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
7772 EXPECT_NE(nullptr, text_position);
7773 EXPECT_TRUE(text_position->IsTextPosition());
7774 EXPECT_EQ(generic_container_12.id, text_position->anchor_id());
7775 EXPECT_EQ(0, text_position->text_offset());
7776
7777 // The following is to test a specific edge case that occurs when all the
7778 // children of a node are ignored and that node could be considered as an
7779 // empty object replaced by character (e.g., a button).
7780 //
7781 // The button element should be treated as a leaf node even though it has a
7782 // child. Because its only child is ignored, the button should be considered
7783 // as an empty object replaced by character and we should be able to create a
7784 // leaf position in the button node.
7785 text_position = AXNodePosition::CreateTextPosition(
7786 GetTreeID(), static_text_13.id, 3 /* text_offset */,
7788 ASSERT_NE(nullptr, text_position);
7789
7790 text_position = text_position->CreateNextParagraphEndPosition(
7791 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7792 EXPECT_NE(nullptr, text_position);
7793 EXPECT_TRUE(text_position->IsTextPosition());
7794 EXPECT_TRUE(text_position->IsLeafTextPosition());
7795 EXPECT_EQ(button_14.id, text_position->anchor_id());
7796 EXPECT_EQ(1, text_position->text_offset());
7797}

◆ TEST_F() [264/325]

ui::TEST_F ( AXPositionTest  ,
GetMaxTextOffsetAndGetTextWithGeneratedContent   
)

Definition at line 1055 of file ax_node_position_unittest.cc.

1055 {
1056 // ++1 kRootWebArea
1057 // ++++2 kTextField
1058 // ++++++3 kStaticText
1059 // ++++++++4 kInlineTextBox
1060 // ++++++5 kStaticText
1061 // ++++++++6 kInlineTextBox
1062 AXNodeData root_1;
1063 AXNodeData text_field_2;
1064 AXNodeData static_text_3;
1065 AXNodeData inline_box_4;
1066 AXNodeData static_text_5;
1067 AXNodeData inline_box_6;
1068
1069 root_1.id = 1;
1070 text_field_2.id = 2;
1071 static_text_3.id = 3;
1072 inline_box_4.id = 4;
1073 static_text_5.id = 5;
1074 inline_box_6.id = 6;
1075
1077 root_1.child_ids = {text_field_2.id};
1078
1079 text_field_2.role = ax::mojom::Role::kGroup;
1080 text_field_2.SetValue("3.14");
1081 text_field_2.child_ids = {static_text_3.id, static_text_5.id};
1082
1083 static_text_3.role = ax::mojom::Role::kStaticText;
1084 static_text_3.SetName("Placeholder from generated content");
1085 static_text_3.child_ids = {inline_box_4.id};
1086
1088 inline_box_4.SetName("Placeholder from generated content");
1089
1090 static_text_5.role = ax::mojom::Role::kStaticText;
1091 static_text_5.SetName("3.14");
1092 static_text_5.child_ids = {inline_box_6.id};
1093
1095 inline_box_6.SetName("3.14");
1096
1097 SetTree(CreateAXTree({root_1, text_field_2, static_text_3, inline_box_4,
1098 static_text_5, inline_box_6}));
1099
1101 GetTreeID(), text_field_2.id, 0 /* text_offset */,
1103 ASSERT_NE(nullptr, text_position);
1104 EXPECT_TRUE(text_position->IsTextPosition());
1105 EXPECT_EQ(38, text_position->MaxTextOffset());
1106 EXPECT_EQ(u"Placeholder from generated content3.14",
1107 text_position->GetText());
1108}

◆ TEST_F() [265/325]

ui::TEST_F ( AXPositionTest  ,
GetMaxTextOffsetFromButton   
)

Definition at line 958 of file ax_node_position_unittest.cc.

958 {
960 GetTreeID(), button_.id, 0 /* text_offset */,
962 ASSERT_NE(nullptr, text_position);
963 ASSERT_TRUE(text_position->IsTextPosition());
964 ASSERT_EQ(0, text_position->MaxTextOffset());
965}

◆ TEST_F() [266/325]

ui::TEST_F ( AXPositionTest  ,
GetMaxTextOffsetFromCheckbox   
)

Definition at line 967 of file ax_node_position_unittest.cc.

967 {
969 GetTreeID(), check_box_.id, 0 /* text_offset */,
971 ASSERT_NE(nullptr, text_position);
972 ASSERT_TRUE(text_position->IsTextPosition());
973 ASSERT_EQ(0, text_position->MaxTextOffset());
974}

◆ TEST_F() [267/325]

ui::TEST_F ( AXPositionTest  ,
GetMaxTextOffsetFromInlineTextBox   
)

Definition at line 994 of file ax_node_position_unittest.cc.

994 {
996 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
998 ASSERT_NE(nullptr, text_position);
999 ASSERT_TRUE(text_position->IsTextPosition());
1000 ASSERT_EQ(6, text_position->MaxTextOffset());
1001}

◆ TEST_F() [268/325]

ui::TEST_F ( AXPositionTest  ,
GetMaxTextOffsetFromLineBreak   
)

Definition at line 1003 of file ax_node_position_unittest.cc.

1003 {
1005 GetTreeID(), line_break_.id, 0 /* text_offset */,
1007 ASSERT_NE(nullptr, text_position);
1008 ASSERT_TRUE(text_position->IsTextPosition());
1009 ASSERT_EQ(1, text_position->MaxTextOffset());
1010}

◆ TEST_F() [269/325]

ui::TEST_F ( AXPositionTest  ,
GetMaxTextOffsetFromNullPosition   
)

Definition at line 942 of file ax_node_position_unittest.cc.

942 {
943 TestPositionType text_position = AXNodePosition::CreateNullPosition();
944 ASSERT_NE(nullptr, text_position);
945 ASSERT_TRUE(text_position->IsNullPosition());
946 ASSERT_EQ(AXNodePosition::INVALID_OFFSET, text_position->MaxTextOffset());
947}

◆ TEST_F() [270/325]

ui::TEST_F ( AXPositionTest  ,
GetMaxTextOffsetFromRoot   
)

Definition at line 949 of file ax_node_position_unittest.cc.

949 {
951 GetTreeID(), root_.id, 0 /* text_offset */,
953 ASSERT_NE(nullptr, text_position);
954 ASSERT_TRUE(text_position->IsTextPosition());
955 ASSERT_EQ(13, text_position->MaxTextOffset());
956}

◆ TEST_F() [271/325]

ui::TEST_F ( AXPositionTest  ,
GetMaxTextOffsetFromStaticText   
)

Definition at line 985 of file ax_node_position_unittest.cc.

985 {
987 GetTreeID(), static_text1_.id, 0 /* text_offset */,
989 ASSERT_NE(nullptr, text_position);
990 ASSERT_TRUE(text_position->IsTextPosition());
991 ASSERT_EQ(6, text_position->MaxTextOffset());
992}

◆ TEST_F() [272/325]

ui::TEST_F ( AXPositionTest  ,
GetMaxTextOffsetFromTextfield   
)

Definition at line 976 of file ax_node_position_unittest.cc.

976 {
978 GetTreeID(), text_field_.id, 0 /* text_offset */,
980 ASSERT_NE(nullptr, text_position);
981 ASSERT_TRUE(text_position->IsTextPosition());
982 ASSERT_EQ(13, text_position->MaxTextOffset());
983}

◆ TEST_F() [273/325]

ui::TEST_F ( AXPositionTest  ,
GetMaxTextOffsetUpdate   
)

Definition at line 1012 of file ax_node_position_unittest.cc.

1012 {
1013 AXNodeData root_data;
1014 root_data.id = 1;
1016
1017 AXNodeData text_data;
1018 text_data.id = 2;
1020 text_data.SetName("some text");
1021
1022 AXNodeData more_text_data;
1023 more_text_data.id = 3;
1024 more_text_data.role = ax::mojom::Role::kStaticText;
1025 more_text_data.SetName("more text");
1026
1027 root_data.child_ids = {2, 3};
1028
1029 SetTree(CreateAXTree({root_data, text_data, more_text_data}));
1030
1031 AssertTextLengthEquals(GetTree(), text_data.id, 9);
1032 AssertTextLengthEquals(GetTree(), root_data.id, 18);
1033
1034 text_data.SetName("Adjusted line 1");
1035 SetTree(CreateAXTree({root_data, text_data, more_text_data}));
1036
1037 AssertTextLengthEquals(GetTree(), text_data.id, 15);
1038 AssertTextLengthEquals(GetTree(), root_data.id, 24);
1039
1040 // Value should override name
1041 text_data.SetValue("Value should override name");
1042 SetTree(CreateAXTree({root_data, text_data, more_text_data}));
1043
1044 AssertTextLengthEquals(GetTree(), text_data.id, 26);
1045 AssertTextLengthEquals(GetTree(), root_data.id, 35);
1046
1047 // An empty value should fall back to name
1048 text_data.SetValue("");
1049 SetTree(CreateAXTree({root_data, text_data, more_text_data}));
1050
1051 AssertTextLengthEquals(GetTree(), text_data.id, 15);
1052 AssertTextLengthEquals(GetTree(), root_data.id, 24);
1053}

◆ TEST_F() [274/325]

ui::TEST_F ( AXPositionTest  ,
GetTextFromButton   
)

Definition at line 888 of file ax_node_position_unittest.cc.

888 {
890 GetTreeID(), button_.id, 0 /* text_offset */,
892 ASSERT_NE(nullptr, text_position);
893 ASSERT_TRUE(text_position->IsTextPosition());
894 ASSERT_EQ(u"", text_position->GetText());
895}

◆ TEST_F() [275/325]

ui::TEST_F ( AXPositionTest  ,
GetTextFromCheckbox   
)

Definition at line 897 of file ax_node_position_unittest.cc.

897 {
899 GetTreeID(), check_box_.id, 0 /* text_offset */,
901 ASSERT_NE(nullptr, text_position);
902 ASSERT_TRUE(text_position->IsTextPosition());
903 ASSERT_EQ(u"", text_position->GetText());
904}

◆ TEST_F() [276/325]

ui::TEST_F ( AXPositionTest  ,
GetTextFromInlineTextBox   
)

Definition at line 924 of file ax_node_position_unittest.cc.

924 {
926 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
928 ASSERT_NE(nullptr, text_position);
929 ASSERT_TRUE(text_position->IsTextPosition());
930 ASSERT_EQ(u"Line 1", text_position->GetText());
931}

◆ TEST_F() [277/325]

ui::TEST_F ( AXPositionTest  ,
GetTextFromLineBreak   
)

Definition at line 933 of file ax_node_position_unittest.cc.

933 {
935 GetTreeID(), line_break_.id, 0 /* text_offset */,
937 ASSERT_NE(nullptr, text_position);
938 ASSERT_TRUE(text_position->IsTextPosition());
939 ASSERT_EQ(u"\n", text_position->GetText());
940}

◆ TEST_F() [278/325]

ui::TEST_F ( AXPositionTest  ,
GetTextFromNullPosition   
)

Definition at line 872 of file ax_node_position_unittest.cc.

872 {
873 TestPositionType text_position = AXNodePosition::CreateNullPosition();
874 ASSERT_NE(nullptr, text_position);
875 ASSERT_TRUE(text_position->IsNullPosition());
876 ASSERT_EQ(u"", text_position->GetText());
877}

◆ TEST_F() [279/325]

ui::TEST_F ( AXPositionTest  ,
GetTextFromRoot   
)

Definition at line 879 of file ax_node_position_unittest.cc.

879 {
881 GetTreeID(), root_.id, 0 /* text_offset */,
883 ASSERT_NE(nullptr, text_position);
884 ASSERT_TRUE(text_position->IsTextPosition());
885 ASSERT_EQ(u"Line 1\nLine 2", text_position->GetText());
886}

◆ TEST_F() [280/325]

ui::TEST_F ( AXPositionTest  ,
GetTextFromStaticText   
)

Definition at line 915 of file ax_node_position_unittest.cc.

915 {
917 GetTreeID(), static_text1_.id, 0 /* text_offset */,
919 ASSERT_NE(nullptr, text_position);
920 ASSERT_TRUE(text_position->IsTextPosition());
921 ASSERT_EQ(u"Line 1", text_position->GetText());
922}

◆ TEST_F() [281/325]

ui::TEST_F ( AXPositionTest  ,
GetTextFromTextField   
)

Definition at line 906 of file ax_node_position_unittest.cc.

906 {
908 GetTreeID(), text_field_.id, 0 /* text_offset */,
910 ASSERT_NE(nullptr, text_position);
911 ASSERT_TRUE(text_position->IsTextPosition());
912 ASSERT_EQ(u"Line 1\nLine 2", text_position->GetText());
913}

◆ TEST_F() [282/325]

ui::TEST_F ( AXPositionTest  ,
IsIgnored   
)

Definition at line 722 of file ax_node_position_unittest.cc.

722 {
723 EXPECT_FALSE(AXNodePosition::CreateNullPosition()->IsIgnored());
724
725 // We now need to update the tree structure to test ignored tree and text
726 // positions.
727 AXNodeData root_data;
728 root_data.id = 1;
730
731 AXNodeData static_text_data_1;
732 static_text_data_1.id = 2;
733 static_text_data_1.role = ax::mojom::Role::kStaticText;
734 static_text_data_1.SetName("One");
735
736 AXNodeData inline_box_data_1;
737 inline_box_data_1.id = 3;
738 inline_box_data_1.role = ax::mojom::Role::kInlineTextBox;
739 inline_box_data_1.SetName("One");
740 inline_box_data_1.AddState(ax::mojom::State::kIgnored);
741
742 AXNodeData container_data;
743 container_data.id = 4;
745 container_data.AddState(ax::mojom::State::kIgnored);
746
747 AXNodeData static_text_data_2;
748 static_text_data_2.id = 5;
749 static_text_data_2.role = ax::mojom::Role::kStaticText;
750 static_text_data_2.SetName("Two");
751
752 AXNodeData inline_box_data_2;
753 inline_box_data_2.id = 6;
754 inline_box_data_2.role = ax::mojom::Role::kInlineTextBox;
755 inline_box_data_2.SetName("Two");
756
757 static_text_data_1.child_ids = {inline_box_data_1.id};
758 container_data.child_ids = {static_text_data_2.id};
759 static_text_data_2.child_ids = {inline_box_data_2.id};
760 root_data.child_ids = {static_text_data_1.id, container_data.id};
761
762 SetTree(
763 CreateAXTree({root_data, static_text_data_1, inline_box_data_1,
764 container_data, static_text_data_2, inline_box_data_2}));
765
766 //
767 // Text positions.
768 //
769
771 GetTreeID(), root_data.id, 0 /* text_offset */,
773 ASSERT_TRUE(text_position_1->IsTextPosition());
774 // Since the leaf node containing the text that is pointed to is ignored, this
775 // position should be ignored.
776 EXPECT_TRUE(text_position_1->IsIgnored());
777
778 // Create a text position before the letter "e" in "One".
780 GetTreeID(), root_data.id, 2 /* text_offset */,
782 ASSERT_TRUE(text_position_2->IsTextPosition());
783 // Same as above.
784 EXPECT_TRUE(text_position_2->IsIgnored());
785
786 // Create a text position before the letter "T" in "Two".
788 GetTreeID(), root_data.id, 3 /* text_offset */,
790 ASSERT_TRUE(text_position_3->IsTextPosition());
791 // Since the leaf node containing the text that is pointed to is not ignored,
792 // but only a generic container that is in between this position and the leaf
793 // node, this position should not be ignored.
794 EXPECT_FALSE(text_position_3->IsIgnored());
795
796 // Create a text position before the letter "w" in "Two".
798 GetTreeID(), root_data.id, 4 /* text_offset */,
800 ASSERT_TRUE(text_position_4->IsTextPosition());
801 // Same as above.
802 EXPECT_FALSE(text_position_4->IsIgnored());
803
804 // But a text position on the ignored generic container itself, should be
805 // ignored.
807 GetTreeID(), container_data.id, 0 /* text_offset */,
809 ASSERT_TRUE(text_position_5->IsTextPosition());
810 EXPECT_TRUE(text_position_5->IsIgnored());
811
812 // Whilst a text position on its static text child should not be ignored since
813 // there is nothing ignore below the generic container.
815 GetTreeID(), static_text_data_2.id, 0 /* text_offset */,
817 ASSERT_TRUE(text_position_6->IsTextPosition());
818 EXPECT_FALSE(text_position_6->IsIgnored());
819
820 // A text position on an ignored leaf node should be ignored.
822 GetTreeID(), inline_box_data_1.id, 1 /* text_offset */,
824 ASSERT_TRUE(text_position_7->IsTextPosition());
825 EXPECT_TRUE(text_position_7->IsIgnored());
826
827 //
828 // Tree positions.
829 //
830
831 // A "before children" position on the root should not be ignored, despite the
832 // fact that the leaf equivalent position is, because we can always adjust to
833 // an unignored position if asked to find the leaf equivalent unignored
834 // position.
835 TestPositionType tree_position_1 = AXNodePosition::CreateTreePosition(
836 GetTreeID(), root_data.id, 0 /* child_index */);
837 ASSERT_TRUE(tree_position_1->IsTreePosition());
838 EXPECT_FALSE(tree_position_1->IsIgnored());
839
840 // A tree position pointing to an ignored child node should be ignored.
841 TestPositionType tree_position_2 = AXNodePosition::CreateTreePosition(
842 GetTreeID(), root_data.id, 1 /* child_index */);
843 ASSERT_TRUE(tree_position_2->IsTreePosition());
844 EXPECT_TRUE(tree_position_2->IsIgnored());
845
846 // An "after text" tree position on an ignored leaf node should be ignored.
847 TestPositionType tree_position_3 = AXNodePosition::CreateTreePosition(
848 GetTreeID(), inline_box_data_1.id, 0 /* child_index */);
849 ASSERT_TRUE(tree_position_3->IsTreePosition());
850 EXPECT_TRUE(tree_position_3->IsIgnored());
851
852 // A "before text" tree position on an ignored leaf node should be ignored.
853 TestPositionType tree_position_4 = AXNodePosition::CreateTreePosition(
854 GetTreeID(), inline_box_data_1.id, AXNodePosition::BEFORE_TEXT);
855 ASSERT_TRUE(tree_position_4->IsTreePosition());
856 EXPECT_TRUE(tree_position_4->IsIgnored());
857
858 // An "after children" tree position on the root node, where the last child is
859 // ignored, should be ignored.
860 TestPositionType tree_position_5 = AXNodePosition::CreateTreePosition(
861 GetTreeID(), root_data.id, 2 /* child_index */);
862 ASSERT_TRUE(tree_position_5->IsTreePosition());
863 EXPECT_TRUE(tree_position_5->IsIgnored());
864
865 // A "before text" position on an unignored node should not be ignored.
866 TestPositionType tree_position_6 = AXNodePosition::CreateTreePosition(
867 GetTreeID(), static_text_data_1.id, AXNodePosition::BEFORE_TEXT);
868 ASSERT_TRUE(tree_position_6->IsTreePosition());
869 EXPECT_FALSE(tree_position_6->IsIgnored());
870}

◆ TEST_F() [283/325]

ui::TEST_F ( AXPositionTest  ,
LowestCommonAncestor   
)

Definition at line 2814 of file ax_node_position_unittest.cc.

2814 {
2815 TestPositionType null_position = AXNodePosition::CreateNullPosition();
2816 ASSERT_NE(nullptr, null_position);
2817 // An "after children" position.
2818 TestPositionType root_position = AXNodePosition::CreateTreePosition(
2819 GetTreeID(), root_.id, 3 /* child_index */);
2820 ASSERT_NE(nullptr, root_position);
2821 // A "before text" position.
2822 TestPositionType button_position = AXNodePosition::CreateTreePosition(
2823 GetTreeID(), button_.id, AXNodePosition::BEFORE_TEXT);
2824 ASSERT_NE(nullptr, button_position);
2825 TestPositionType text_field_position = AXNodePosition::CreateTreePosition(
2826 GetTreeID(), text_field_.id, 2 /* child_index */);
2827 ASSERT_NE(nullptr, text_field_position);
2828 TestPositionType static_text1_position = AXNodePosition::CreateTreePosition(
2829 GetTreeID(), static_text1_.id, 0 /* child_index */);
2830 ASSERT_NE(nullptr, static_text1_position);
2831 TestPositionType static_text2_position = AXNodePosition::CreateTreePosition(
2832 GetTreeID(), static_text2_.id, 0 /* child_index */);
2833 ASSERT_NE(nullptr, static_text2_position);
2835 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
2837 ASSERT_NE(nullptr, inline_box1_position);
2838 ASSERT_TRUE(inline_box1_position->IsTextPosition());
2840 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
2842 ASSERT_NE(nullptr, inline_box2_position);
2843 ASSERT_TRUE(inline_box2_position->IsTextPosition());
2844
2845 TestPositionType test_position =
2846 root_position->LowestCommonAncestor(*null_position.get());
2847 EXPECT_NE(nullptr, test_position);
2848 EXPECT_TRUE(test_position->IsNullPosition());
2849
2850 test_position = root_position->LowestCommonAncestor(*root_position.get());
2851 EXPECT_NE(nullptr, test_position);
2852 EXPECT_TRUE(test_position->IsTreePosition());
2853 EXPECT_EQ(root_.id, test_position->anchor_id());
2854 // The child index should be for an "after children" position, i.e. it should
2855 // be unchanged.
2856 EXPECT_EQ(3, test_position->child_index());
2857
2858 test_position =
2859 button_position->LowestCommonAncestor(*text_field_position.get());
2860 EXPECT_NE(nullptr, test_position);
2861 EXPECT_TRUE(test_position->IsTreePosition());
2862 EXPECT_EQ(root_.id, test_position->anchor_id());
2863 // The child index should point to the button.
2864 EXPECT_EQ(0, test_position->child_index());
2865
2866 test_position =
2867 static_text2_position->LowestCommonAncestor(*static_text1_position.get());
2868 EXPECT_NE(nullptr, test_position);
2869 EXPECT_TRUE(test_position->IsTreePosition());
2870 EXPECT_EQ(text_field_.id, test_position->anchor_id());
2871 // The child index should point to the second static text node.
2872 EXPECT_EQ(2, test_position->child_index());
2873
2874 test_position =
2875 static_text1_position->LowestCommonAncestor(*text_field_position.get());
2876 EXPECT_NE(nullptr, test_position);
2877 EXPECT_TRUE(test_position->IsTreePosition());
2878 EXPECT_EQ(text_field_.id, test_position->anchor_id());
2879 // The child index should point to the first static text node.
2880 EXPECT_EQ(0, test_position->child_index());
2881
2882 test_position =
2883 inline_box1_position->LowestCommonAncestor(*inline_box2_position.get());
2884 EXPECT_NE(nullptr, test_position);
2885 EXPECT_TRUE(test_position->IsTextPosition());
2886 EXPECT_EQ(text_field_.id, test_position->anchor_id());
2887 EXPECT_EQ(0, test_position->text_offset());
2888
2889 test_position =
2890 inline_box2_position->LowestCommonAncestor(*inline_box1_position.get());
2891 EXPECT_NE(nullptr, test_position);
2892 EXPECT_TRUE(test_position->IsTextPosition());
2893 EXPECT_EQ(text_field_.id, test_position->anchor_id());
2894 // The text offset should point to the second line.
2895 EXPECT_EQ(7, test_position->text_offset());
2896}

◆ TEST_F() [284/325]

ui::TEST_F ( AXPositionTest  ,
MoveByFormatWithIgnoredNodes   
)

Definition at line 4340 of file ax_node_position_unittest.cc.

4340 {
4341 // ++1 kRootWebArea
4342 // ++++2 kGenericContainer
4343 // ++++++3 kButton
4344 // ++++++++4 kStaticText
4345 // ++++++++++5 kInlineTextBox
4346 // ++++++++6 kSvgRoot ignored
4347 // ++++++++++7 kGenericContainer ignored
4348 // ++++8 kGenericContainer
4349 // ++++++9 kHeading
4350 // ++++++++10 kStaticText
4351 // ++++++++++11 kInlineTextBox
4352 // ++++++12 kStaticText
4353 // ++++++++13 kInlineTextBox
4354 // ++++++14 kGenericContainer ignored
4355 // ++++15 kGenericContainer
4356 // ++++++16 kHeading
4357 // ++++++++17 kStaticText
4358 // ++++++++++18 kInlineTextBox
4359 // ++++19 kGenericContainer
4360 // ++++++20 kGenericContainer ignored
4361 // ++++++21 kStaticText
4362 // ++++++++22 kInlineTextBox
4363 // ++++++23 kHeading
4364 // ++++++++24 kStaticText
4365 // ++++++++++25 kInlineTextBox
4366 AXNodeData root_1;
4367 AXNodeData generic_container_2;
4368 AXNodeData button_3;
4369 AXNodeData static_text_4;
4370 AXNodeData inline_box_5;
4371 AXNodeData svg_root_6;
4372 AXNodeData generic_container_7;
4373 AXNodeData generic_container_8;
4374 AXNodeData heading_9;
4375 AXNodeData static_text_10;
4376 AXNodeData inline_box_11;
4377 AXNodeData static_text_12;
4378 AXNodeData inline_box_13;
4379 AXNodeData generic_container_14;
4380 AXNodeData generic_container_15;
4381 AXNodeData heading_16;
4382 AXNodeData static_text_17;
4383 AXNodeData inline_box_18;
4384 AXNodeData generic_container_19;
4385 AXNodeData generic_container_20;
4386 AXNodeData static_text_21;
4387 AXNodeData inline_box_22;
4388 AXNodeData heading_23;
4389 AXNodeData static_text_24;
4390 AXNodeData inline_box_25;
4391
4392 root_1.id = 1;
4393 generic_container_2.id = 2;
4394 button_3.id = 3;
4395 static_text_4.id = 4;
4396 inline_box_5.id = 5;
4397 svg_root_6.id = 6;
4398 generic_container_7.id = 7;
4399 generic_container_8.id = 8;
4400 heading_9.id = 9;
4401 static_text_10.id = 10;
4402 inline_box_11.id = 11;
4403 static_text_12.id = 12;
4404 inline_box_13.id = 13;
4405 generic_container_14.id = 14;
4406 generic_container_15.id = 15;
4407 heading_16.id = 16;
4408 static_text_17.id = 17;
4409 inline_box_18.id = 18;
4410 generic_container_19.id = 19;
4411 generic_container_20.id = 20;
4412 static_text_21.id = 21;
4413 inline_box_22.id = 22;
4414 heading_23.id = 23;
4415 static_text_24.id = 24;
4416 inline_box_25.id = 25;
4417
4419 root_1.child_ids = {generic_container_2.id, generic_container_8.id,
4420 generic_container_15.id, generic_container_19.id};
4421
4422 generic_container_2.role = ax::mojom::Role::kGenericContainer;
4423 generic_container_2.child_ids = {button_3.id};
4424
4425 button_3.role = ax::mojom::Role::kButton;
4426 button_3.child_ids = {static_text_4.id, svg_root_6.id};
4427
4428 static_text_4.role = ax::mojom::Role::kStaticText;
4429 static_text_4.child_ids = {inline_box_5.id};
4430 static_text_4.SetName("Button");
4431
4433 inline_box_5.SetName("Button");
4434
4435 svg_root_6.role = ax::mojom::Role::kSvgRoot;
4436 svg_root_6.child_ids = {generic_container_7.id};
4438
4439 generic_container_7.role = ax::mojom::Role::kGenericContainer;
4440 generic_container_7.AddState(ax::mojom::State::kIgnored);
4441
4442 generic_container_8.role = ax::mojom::Role::kGenericContainer;
4443 generic_container_8.child_ids = {heading_9.id, static_text_12.id,
4444 generic_container_14.id};
4445
4446 heading_9.role = ax::mojom::Role::kHeading;
4447 heading_9.child_ids = {static_text_10.id};
4448
4449 static_text_10.role = ax::mojom::Role::kStaticText;
4450 static_text_10.child_ids = {inline_box_11.id};
4451 static_text_10.SetName("Heading");
4452
4453 inline_box_11.role = ax::mojom::Role::kInlineTextBox;
4454 inline_box_11.SetName("Heading");
4455
4456 static_text_12.role = ax::mojom::Role::kStaticText;
4457 static_text_12.child_ids = {inline_box_13.id};
4458 static_text_12.SetName("3.14");
4459
4460 inline_box_13.role = ax::mojom::Role::kInlineTextBox;
4461 inline_box_13.SetName("3.14");
4462
4463 generic_container_14.role = ax::mojom::Role::kGenericContainer;
4464 generic_container_14.AddState(ax::mojom::State::kIgnored);
4465
4466 generic_container_15.role = ax::mojom::Role::kGenericContainer;
4467 generic_container_15.child_ids = {heading_16.id};
4468
4469 heading_16.role = ax::mojom::Role::kHeading;
4470 heading_16.child_ids = {static_text_17.id};
4471
4472 static_text_17.role = ax::mojom::Role::kStaticText;
4473 static_text_17.child_ids = {inline_box_18.id};
4474 static_text_17.SetName("Heading");
4475
4476 inline_box_18.role = ax::mojom::Role::kInlineTextBox;
4477 inline_box_18.SetName("Heading");
4478
4479 generic_container_19.role = ax::mojom::Role::kGenericContainer;
4480 generic_container_19.child_ids = {generic_container_20.id, static_text_21.id,
4481 heading_23.id};
4482
4483 generic_container_20.role = ax::mojom::Role::kGenericContainer;
4484 generic_container_20.AddState(ax::mojom::State::kIgnored);
4485
4486 static_text_21.role = ax::mojom::Role::kStaticText;
4487 static_text_21.child_ids = {inline_box_22.id};
4488 static_text_21.SetName("3.14");
4489
4490 inline_box_22.role = ax::mojom::Role::kInlineTextBox;
4491 inline_box_22.SetName("3.14");
4492
4493 heading_23.role = ax::mojom::Role::kHeading;
4494 heading_23.child_ids = {static_text_24.id};
4495
4496 static_text_24.role = ax::mojom::Role::kStaticText;
4497 static_text_24.child_ids = {inline_box_25.id};
4498 static_text_24.SetName("Heading");
4499
4500 inline_box_25.role = ax::mojom::Role::kInlineTextBox;
4501 inline_box_25.SetName("Heading");
4502
4503 SetTree(CreateAXTree({root_1,
4504 generic_container_2,
4505 button_3,
4506 static_text_4,
4507 inline_box_5,
4508 svg_root_6,
4509 generic_container_7,
4510 generic_container_8,
4511 heading_9,
4512 static_text_10,
4513 inline_box_11,
4514 static_text_12,
4515 inline_box_13,
4516 generic_container_14,
4517 generic_container_15,
4518 heading_16,
4519 static_text_17,
4520 inline_box_18,
4521 generic_container_19,
4522 generic_container_20,
4523 static_text_21,
4524 inline_box_22,
4525 heading_23,
4526 static_text_24,
4527 inline_box_25}));
4528
4529 // There are two major cases to consider for format boundaries with ignored
4530 // nodes:
4531 // Case 1: When the ignored node is directly next to the current position.
4532 // Case 2: When the ignored node is directly next to the next/previous format
4533 // boundary.
4534
4535 // Case 1
4536 // This test case spans nodes 2 to 11, inclusively.
4537 {
4538 // Forward movement
4540 GetTreeID(), inline_box_5.id, 6 /* text_offset */,
4542 ASSERT_NE(nullptr, text_position);
4543 EXPECT_TRUE(text_position->IsTextPosition());
4544 EXPECT_EQ(inline_box_5.id, text_position->anchor_id());
4545 EXPECT_EQ(6, text_position->text_offset());
4546
4547 text_position = text_position->CreateNextFormatEndPosition(
4548 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4549 ASSERT_NE(nullptr, text_position);
4550 EXPECT_TRUE(text_position->IsTextPosition());
4551 EXPECT_EQ(inline_box_11.id, text_position->anchor_id());
4552 EXPECT_EQ(7, text_position->text_offset());
4553
4554 // Backward movement
4555 text_position = AXNodePosition::CreateTextPosition(
4556 GetTreeID(), inline_box_11.id, 0 /* text_offset */,
4558 ASSERT_NE(nullptr, text_position);
4559 EXPECT_TRUE(text_position->IsTextPosition());
4560 EXPECT_EQ(inline_box_11.id, text_position->anchor_id());
4561 EXPECT_EQ(0, text_position->text_offset());
4562
4563 text_position = text_position->CreatePreviousFormatStartPosition(
4564 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4565 ASSERT_NE(nullptr, text_position);
4566 EXPECT_TRUE(text_position->IsTextPosition());
4567 EXPECT_EQ(inline_box_5.id, text_position->anchor_id());
4568 EXPECT_EQ(0, text_position->text_offset());
4569 }
4570
4571 // Case 2
4572 // This test case spans nodes 8 to 25.
4573 {
4574 // Forward movement
4576 GetTreeID(), inline_box_11.id, 7 /* text_offset */,
4578 ASSERT_NE(nullptr, text_position);
4579 EXPECT_TRUE(text_position->IsTextPosition());
4580 EXPECT_EQ(inline_box_11.id, text_position->anchor_id());
4581 EXPECT_EQ(7, text_position->text_offset());
4582
4583 text_position = text_position->CreateNextFormatEndPosition(
4584 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4585 ASSERT_NE(nullptr, text_position);
4586 EXPECT_TRUE(text_position->IsTextPosition());
4587 EXPECT_EQ(inline_box_13.id, text_position->anchor_id());
4588 EXPECT_EQ(4, text_position->text_offset());
4589
4590 // Backward movement
4591 text_position = AXNodePosition::CreateTextPosition(
4592 GetTreeID(), inline_box_25.id, 0 /* text_offset */,
4594 ASSERT_NE(nullptr, text_position);
4595 EXPECT_TRUE(text_position->IsTextPosition());
4596 EXPECT_EQ(inline_box_25.id, text_position->anchor_id());
4597 EXPECT_EQ(0, text_position->text_offset());
4598
4599 text_position = text_position->CreatePreviousFormatStartPosition(
4600 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4601 ASSERT_NE(nullptr, text_position);
4602 EXPECT_TRUE(text_position->IsTextPosition());
4603 EXPECT_EQ(inline_box_22.id, text_position->anchor_id());
4604 EXPECT_EQ(0, text_position->text_offset());
4605 }
4606}

◆ TEST_F() [285/325]

ui::TEST_F ( AXPositionTest  ,
OperatorEquals   
)

Definition at line 6625 of file ax_node_position_unittest.cc.

6625 {
6626 TestPositionType null_position1 = AXNodePosition::CreateNullPosition();
6627 ASSERT_NE(nullptr, null_position1);
6628 TestPositionType null_position2 = AXNodePosition::CreateNullPosition();
6629 ASSERT_NE(nullptr, null_position2);
6630 EXPECT_EQ(*null_position1, *null_position2);
6631
6632 // Child indices must match.
6633 TestPositionType button_position1 = AXNodePosition::CreateTreePosition(
6634 GetTreeID(), root_.id, 0 /* child_index */);
6635 ASSERT_NE(nullptr, button_position1);
6636 TestPositionType button_position2 = AXNodePosition::CreateTreePosition(
6637 GetTreeID(), root_.id, 0 /* child_index */);
6638 ASSERT_NE(nullptr, button_position2);
6639 EXPECT_EQ(*button_position1, *button_position2);
6640
6641 // Both child indices are invalid. It should result in equivalent null
6642 // positions.
6643 TestPositionType tree_position1 = AXNodePosition::CreateTreePosition(
6644 GetTreeID(), root_.id, 4 /* child_index */);
6645 ASSERT_NE(nullptr, tree_position1);
6646 TestPositionType tree_position2 = AXNodePosition::CreateTreePosition(
6647 GetTreeID(), root_.id, AXNodePosition::INVALID_INDEX);
6648 ASSERT_NE(nullptr, tree_position2);
6649 EXPECT_EQ(*tree_position1, *tree_position2);
6650
6651 // An invalid position should not be equivalent to an "after children"
6652 // position.
6653 tree_position1 = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
6654 3 /* child_index */);
6655 ASSERT_NE(nullptr, tree_position1);
6656 tree_position2 = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
6657 -1 /* child_index */);
6658 ASSERT_NE(nullptr, tree_position2);
6659 EXPECT_NE(*tree_position1, *tree_position2);
6660
6661 // Two "after children" positions on the same node should be equivalent.
6662 tree_position1 = AXNodePosition::CreateTreePosition(
6663 GetTreeID(), text_field_.id, 3 /* child_index */);
6664 ASSERT_NE(nullptr, tree_position1);
6665 tree_position2 = AXNodePosition::CreateTreePosition(
6666 GetTreeID(), text_field_.id, 3 /* child_index */);
6667 ASSERT_NE(nullptr, tree_position2);
6668 EXPECT_EQ(*tree_position1, *tree_position2);
6669
6670 // Two "before text" positions on the same node should be equivalent.
6671 tree_position1 = AXNodePosition::CreateTreePosition(
6672 GetTreeID(), inline_box1_.id, AXNodePosition::BEFORE_TEXT);
6673 ASSERT_NE(nullptr, tree_position1);
6674 tree_position2 = AXNodePosition::CreateTreePosition(
6675 GetTreeID(), inline_box1_.id, AXNodePosition::BEFORE_TEXT);
6676 ASSERT_NE(nullptr, tree_position2);
6677 EXPECT_EQ(*tree_position1, *tree_position2);
6678
6679 // Both text offsets are invalid. It should result in equivalent null
6680 // positions.
6682 GetTreeID(), inline_box1_.id, 15 /* text_offset */,
6684 ASSERT_NE(nullptr, text_position1);
6685 ASSERT_TRUE(text_position1->IsNullPosition());
6687 GetTreeID(), text_field_.id, -1 /* text_offset */,
6689 ASSERT_NE(nullptr, text_position2);
6690 ASSERT_TRUE(text_position2->IsNullPosition());
6691 EXPECT_EQ(*text_position1, *text_position2);
6692
6693 text_position1 = AXNodePosition::CreateTextPosition(
6694 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
6696 ASSERT_NE(nullptr, text_position1);
6697 ASSERT_TRUE(text_position1->IsTextPosition());
6698 text_position2 = AXNodePosition::CreateTextPosition(
6699 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
6701 ASSERT_NE(nullptr, text_position2);
6702 ASSERT_TRUE(text_position2->IsTextPosition());
6703 EXPECT_EQ(*text_position1, *text_position2);
6704
6705 // Affinities should not matter.
6706 text_position2 = AXNodePosition::CreateTextPosition(
6707 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
6709 ASSERT_NE(nullptr, text_position2);
6710 ASSERT_TRUE(text_position2->IsTextPosition());
6711 EXPECT_EQ(*text_position1, *text_position2);
6712
6713 // Text offsets should match.
6714 text_position1 = AXNodePosition::CreateTextPosition(
6715 GetTreeID(), inline_box1_.id, 5 /* text_offset */,
6717 ASSERT_NE(nullptr, text_position1);
6718 ASSERT_TRUE(text_position1->IsTextPosition());
6719 EXPECT_NE(*text_position1, *text_position2);
6720
6721 // Two "after text" positions on the same node should be equivalent.
6722 text_position1 = AXNodePosition::CreateTextPosition(
6723 GetTreeID(), line_break_.id, 1 /* text_offset */,
6725 ASSERT_NE(nullptr, text_position1);
6726 ASSERT_TRUE(text_position1->IsTextPosition());
6727 text_position2 = AXNodePosition::CreateTextPosition(
6728 GetTreeID(), line_break_.id, 1 /* text_offset */,
6730 ASSERT_NE(nullptr, text_position2);
6731 ASSERT_TRUE(text_position2->IsTextPosition());
6732 EXPECT_EQ(*text_position1, *text_position2);
6733
6734 // Two text positions that are consecutive, one "before text" and one "after
6735 // text".
6736 text_position1 = AXNodePosition::CreateTextPosition(
6737 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
6739 ASSERT_NE(nullptr, text_position1);
6740 ASSERT_TRUE(text_position1->IsTextPosition());
6741 text_position2 = AXNodePosition::CreateTextPosition(
6742 GetTreeID(), line_break_.id, 1 /* text_offset */,
6744 ASSERT_NE(nullptr, text_position2);
6745 ASSERT_TRUE(text_position2->IsTextPosition());
6746 EXPECT_EQ(*text_position1, *text_position2);
6747
6748 // Two "after text" positions on a parent and child should be equivalent, in
6749 // the middle of the document...
6750 text_position1 = AXNodePosition::CreateTextPosition(
6751 GetTreeID(), static_text1_.id, 6 /* text_offset */,
6753 ASSERT_NE(nullptr, text_position1);
6754 ASSERT_TRUE(text_position1->IsTextPosition());
6755 text_position2 = AXNodePosition::CreateTextPosition(
6756 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
6758 ASSERT_NE(nullptr, text_position2);
6759 ASSERT_TRUE(text_position2->IsTextPosition());
6760 EXPECT_EQ(*text_position1, *text_position2);
6761
6762 // ...and at the end of the document.
6763 text_position1 = AXNodePosition::CreateTextPosition(
6764 GetTreeID(), static_text2_.id, 6 /* text_offset */,
6766 ASSERT_NE(nullptr, text_position1);
6767 ASSERT_TRUE(text_position1->IsTextPosition());
6768 text_position2 = AXNodePosition::CreateTextPosition(
6769 GetTreeID(), inline_box2_.id, 6 /* text_offset */,
6771 ASSERT_NE(nullptr, text_position2);
6772 ASSERT_TRUE(text_position2->IsTextPosition());
6773 // Validate that we're actually at the end of the document by normalizing to
6774 // the equivalent "before character" position.
6776 text_position1->AsLeafTextPositionBeforeCharacter()->IsNullPosition());
6778 text_position2->AsLeafTextPositionBeforeCharacter()->IsNullPosition());
6779 // Now compare the positions.
6780 EXPECT_EQ(*text_position1, *text_position2);
6781}

◆ TEST_F() [286/325]

ui::TEST_F ( AXPositionTest  ,
OperatorEqualsSameTextOffsetDifferentAnchorIdLeaf   
)

Definition at line 6817 of file ax_node_position_unittest.cc.

6817 {
6819 GetTreeID(), button_.id, 0 /* text_offset */,
6821 ASSERT_NE(nullptr, text_position_one);
6822 ASSERT_TRUE(text_position_one->IsTextPosition());
6823
6825 GetTreeID(), check_box_.id, 0 /* text_offset */,
6827 ASSERT_NE(nullptr, text_position_two);
6828 ASSERT_TRUE(text_position_two->IsTextPosition());
6829
6830 ASSERT_TRUE(*text_position_one == *text_position_two);
6831 ASSERT_TRUE(*text_position_two == *text_position_one);
6832}

◆ TEST_F() [287/325]

ui::TEST_F ( AXPositionTest  ,
OperatorEqualsSameTextOffsetDifferentAnchorIdRoot   
)

Definition at line 6800 of file ax_node_position_unittest.cc.

6800 {
6802 GetTreeID(), root_.id, 0 /* text_offset */,
6804 ASSERT_NE(nullptr, text_position_one);
6805 ASSERT_TRUE(text_position_one->IsTextPosition());
6806
6808 GetTreeID(), check_box_.id, 0 /* text_offset */,
6810 ASSERT_NE(nullptr, text_position_two);
6811 ASSERT_TRUE(text_position_two->IsTextPosition());
6812
6813 ASSERT_TRUE(*text_position_one == *text_position_two);
6814 ASSERT_TRUE(*text_position_two == *text_position_one);
6815}

◆ TEST_F() [288/325]

ui::TEST_F ( AXPositionTest  ,
OperatorEqualsSameTextOffsetSameAnchorId   
)

Definition at line 6783 of file ax_node_position_unittest.cc.

6783 {
6785 GetTreeID(), root_.id, 0 /* text_offset */,
6787 ASSERT_NE(nullptr, text_position_one);
6788 ASSERT_TRUE(text_position_one->IsTextPosition());
6789
6791 GetTreeID(), root_.id, 0 /* text_offset */,
6793 ASSERT_NE(nullptr, text_position_two);
6794 ASSERT_TRUE(text_position_two->IsTextPosition());
6795
6796 ASSERT_TRUE(*text_position_one == *text_position_two);
6797 ASSERT_TRUE(*text_position_two == *text_position_one);
6798}

◆ TEST_F() [289/325]

ui::TEST_F ( AXPositionTest  ,
OperatorsLessThanAndGreaterThan   
)

Definition at line 6834 of file ax_node_position_unittest.cc.

6834 {
6835 TestPositionType null_position1 = AXNodePosition::CreateNullPosition();
6836 ASSERT_NE(nullptr, null_position1);
6837 TestPositionType null_position2 = AXNodePosition::CreateNullPosition();
6838 ASSERT_NE(nullptr, null_position2);
6839 EXPECT_FALSE(*null_position1 < *null_position2);
6840 EXPECT_FALSE(*null_position1 > *null_position2);
6841
6842 TestPositionType button_position1 = AXNodePosition::CreateTreePosition(
6843 GetTreeID(), root_.id, 0 /* child_index */);
6844 ASSERT_NE(nullptr, button_position1);
6845 TestPositionType button_position2 = AXNodePosition::CreateTreePosition(
6846 GetTreeID(), root_.id, 1 /* child_index */);
6847 ASSERT_NE(nullptr, button_position2);
6848 EXPECT_LT(*button_position1, *button_position2);
6849 EXPECT_GT(*button_position2, *button_position1);
6850
6851 TestPositionType tree_position1 = AXNodePosition::CreateTreePosition(
6852 GetTreeID(), text_field_.id, 2 /* child_index */);
6853 ASSERT_NE(nullptr, tree_position1);
6854 // An "after children" position.
6855 TestPositionType tree_position2 = AXNodePosition::CreateTreePosition(
6856 GetTreeID(), text_field_.id, 3 /* child_index */);
6857 ASSERT_NE(nullptr, tree_position2);
6858 EXPECT_LT(*tree_position1, *tree_position2);
6859 EXPECT_GT(*tree_position2, *tree_position1);
6860
6861 // A "before text" position.
6862 tree_position1 = AXNodePosition::CreateTreePosition(
6863 GetTreeID(), inline_box1_.id, AXNodePosition::BEFORE_TEXT);
6864 ASSERT_NE(nullptr, tree_position1);
6865 // An "after text" position.
6866 tree_position2 = AXNodePosition::CreateTreePosition(
6867 GetTreeID(), inline_box1_.id, 0 /* child_index */);
6868 ASSERT_NE(nullptr, tree_position2);
6869 EXPECT_LT(*tree_position1, *tree_position2);
6870 EXPECT_GT(*tree_position2, *tree_position1);
6871
6872 // Two text positions that share a common anchor.
6874 GetTreeID(), inline_box1_.id, 2 /* text_offset */,
6876 ASSERT_NE(nullptr, text_position1);
6877 ASSERT_TRUE(text_position1->IsTextPosition());
6879 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
6881 ASSERT_NE(nullptr, text_position2);
6882 ASSERT_TRUE(text_position2->IsTextPosition());
6883 EXPECT_GT(*text_position1, *text_position2);
6884 EXPECT_LT(*text_position2, *text_position1);
6885
6886 // Affinities should not matter.
6887 text_position2 = AXNodePosition::CreateTextPosition(
6888 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
6890 ASSERT_NE(nullptr, text_position2);
6891 ASSERT_TRUE(text_position2->IsTextPosition());
6892 EXPECT_GT(*text_position1, *text_position2);
6893 EXPECT_LT(*text_position2, *text_position1);
6894
6895 // An "after text" position.
6896 text_position1 = AXNodePosition::CreateTextPosition(
6897 GetTreeID(), line_break_.id, 1 /* text_offset */,
6899 ASSERT_NE(nullptr, text_position1);
6900 ASSERT_TRUE(text_position1->IsTextPosition());
6901 // A "before text" position.
6902 text_position2 = AXNodePosition::CreateTextPosition(
6903 GetTreeID(), line_break_.id, 0 /* text_offset */,
6905 ASSERT_NE(nullptr, text_position2);
6906 ASSERT_TRUE(text_position2->IsTextPosition());
6907 EXPECT_GT(*text_position1, *text_position2);
6908 EXPECT_LT(*text_position2, *text_position1);
6909
6910 // A text position that is an ancestor of another.
6911 text_position1 = AXNodePosition::CreateTextPosition(
6912 GetTreeID(), text_field_.id, 6 /* text_offset */,
6914 ASSERT_NE(nullptr, text_position1);
6915 ASSERT_TRUE(text_position1->IsTextPosition());
6916 text_position2 = AXNodePosition::CreateTextPosition(
6917 GetTreeID(), inline_box1_.id, 5 /* text_offset */,
6919 ASSERT_NE(nullptr, text_position2);
6920 ASSERT_TRUE(text_position2->IsTextPosition());
6921 EXPECT_GT(*text_position1, *text_position2);
6922 EXPECT_LT(*text_position2, *text_position1);
6923
6924 // Two text positions that share a common ancestor.
6925 text_position1 = AXNodePosition::CreateTextPosition(
6926 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
6928 ASSERT_NE(nullptr, text_position1);
6929 ASSERT_TRUE(text_position1->IsTextPosition());
6930 text_position2 = AXNodePosition::CreateTextPosition(
6931 GetTreeID(), line_break_.id, 0 /* text_offset */,
6933 ASSERT_NE(nullptr, text_position2);
6934 ASSERT_TRUE(text_position2->IsTextPosition());
6935 EXPECT_GT(*text_position1, *text_position2);
6936 EXPECT_LT(*text_position2, *text_position1);
6937
6938 // Two consecutive positions. One "before text" and one "after text".
6939 text_position2 = AXNodePosition::CreateTextPosition(
6940 GetTreeID(), line_break_.id, 1 /* text_offset */,
6942 ASSERT_NE(nullptr, text_position2);
6943 ASSERT_TRUE(text_position2->IsTextPosition());
6944 EXPECT_EQ(*text_position1, *text_position2);
6945
6946 // A text position at the end of the document versus one that isn't.
6947 text_position1 = AXNodePosition::CreateTextPosition(
6948 GetTreeID(), inline_box2_.id, 6 /* text_offset */,
6950 ASSERT_NE(nullptr, text_position1);
6951 ASSERT_TRUE(text_position1->IsTextPosition());
6952 // Validate that we're actually at the end of the document by normalizing to
6953 // the equivalent "before character" position.
6955 text_position1->AsLeafTextPositionBeforeCharacter()->IsNullPosition());
6956 // Now create the not-at-end-of-document position and compare.
6957 text_position2 = AXNodePosition::CreateTextPosition(
6958 GetTreeID(), static_text2_.id, 0 /* text_offset */,
6960 ASSERT_NE(nullptr, text_position2);
6961 ASSERT_TRUE(text_position2->IsTextPosition());
6962 EXPECT_GT(*text_position1, *text_position2);
6963 EXPECT_LT(*text_position2, *text_position1);
6964}

◆ TEST_F() [290/325]

ui::TEST_F ( AXPositionTest  ,
ParagraphEdgesWithPreservedNewLine   
)

Definition at line 1816 of file ax_node_position_unittest.cc.

1816 {
1817 // This test ensures that "At{Start|End}OfParagraph" work correctly when a
1818 // text position is on a preserved newline character.
1819 //
1820 // Newline characters are used to separate paragraphs. If there is a series of
1821 // newline characters, a paragraph should start after the last newline
1822 // character.
1823 // ++1 kRootWebArea isLineBreakingObject
1824 // ++++2 kStaticText "some text"
1825 // ++++++3 kInlineTextBox "some text"
1826 // ++++4 kGenericContainer isLineBreakingObject
1827 // ++++++5 kStaticText "\nmore text"
1828 // ++++++++6 kInlineTextBox "\n" isLineBreakingObject
1829 // ++++++++7 kInlineTextBox "more text"
1830
1831 AXNodeData root_data;
1832 root_data.id = 1;
1835 true);
1836
1837 AXNodeData static_text_data_1;
1838 static_text_data_1.id = 2;
1839 static_text_data_1.role = ax::mojom::Role::kStaticText;
1840 static_text_data_1.SetName("some text");
1841
1842 AXNodeData some_text_data;
1843 some_text_data.id = 3;
1844 some_text_data.role = ax::mojom::Role::kInlineTextBox;
1845 some_text_data.SetName("some text");
1846
1847 AXNodeData container_data;
1848 container_data.id = 4;
1850 container_data.AddBoolAttribute(
1852
1853 AXNodeData static_text_data_2;
1854 static_text_data_2.id = 5;
1855 static_text_data_2.role = ax::mojom::Role::kStaticText;
1856 static_text_data_2.SetName("\nmore text");
1857
1858 AXNodeData preserved_newline_data;
1859 preserved_newline_data.id = 6;
1860 preserved_newline_data.role = ax::mojom::Role::kInlineTextBox;
1861 preserved_newline_data.SetName("\n");
1862 preserved_newline_data.AddBoolAttribute(
1864
1865 AXNodeData more_text_data;
1866 more_text_data.id = 7;
1867 more_text_data.role = ax::mojom::Role::kInlineTextBox;
1868 more_text_data.SetName("more text");
1869
1870 static_text_data_1.child_ids = {some_text_data.id};
1871 container_data.child_ids = {static_text_data_2.id};
1872 static_text_data_2.child_ids = {preserved_newline_data.id, more_text_data.id};
1873 root_data.child_ids = {static_text_data_1.id, container_data.id};
1874
1875 SetTree(CreateAXTree({root_data, static_text_data_1, some_text_data,
1876 container_data, static_text_data_2,
1877 preserved_newline_data, more_text_data}));
1878
1879 // Text position "some tex<t>\nmore text".
1881 GetTreeID(), root_data.id, 8 /* text_offset */,
1883 EXPECT_FALSE(text_position1->AtEndOfParagraph());
1884 EXPECT_FALSE(text_position1->AtStartOfParagraph());
1885
1886 // Text position "some text<\n>more text".
1888 GetTreeID(), root_data.id, 9 /* text_offset */,
1890 EXPECT_FALSE(text_position2->AtEndOfParagraph());
1891 EXPECT_FALSE(text_position2->AtStartOfParagraph());
1892
1893 // Text position "some text<\n>more text".
1895 GetTreeID(), root_data.id, 9 /* text_offset */,
1897 EXPECT_FALSE(text_position3->AtEndOfParagraph());
1898 EXPECT_FALSE(text_position3->AtStartOfParagraph());
1899
1900 // Text position "some text\n<m>ore text".
1902 GetTreeID(), root_data.id, 10 /* text_offset */,
1904 EXPECT_FALSE(text_position4->AtEndOfParagraph());
1905 EXPECT_TRUE(text_position4->AtStartOfParagraph());
1906
1907 // Text position "some text\n<m>ore text".
1909 GetTreeID(), root_data.id, 10 /* text_offset */,
1911 EXPECT_TRUE(text_position5->AtEndOfParagraph());
1912 EXPECT_FALSE(text_position5->AtStartOfParagraph());
1913
1914 // Text position "<\n>more text".
1916 GetTreeID(), container_data.id, 0 /* text_offset */,
1918 EXPECT_FALSE(text_position6->AtEndOfParagraph());
1919 EXPECT_FALSE(text_position6->AtStartOfParagraph());
1920
1921 // Text position "\n<m>ore text".
1923 GetTreeID(), container_data.id, 1 /* text_offset */,
1925 EXPECT_FALSE(text_position7->AtEndOfParagraph());
1926 EXPECT_TRUE(text_position7->AtStartOfParagraph());
1927
1928 // Text position "\n<m>ore text".
1930 GetTreeID(), container_data.id, 1 /* text_offset */,
1932 EXPECT_TRUE(text_position8->AtEndOfParagraph());
1933 EXPECT_FALSE(text_position8->AtStartOfParagraph());
1934
1935 // Text position "\n<m>ore text".
1937 GetTreeID(), static_text_data_2.id, 1 /* text_offset */,
1939 EXPECT_FALSE(text_position9->AtEndOfParagraph());
1940 EXPECT_TRUE(text_position9->AtStartOfParagraph());
1941
1942 // Text position "\n<m>ore text".
1944 GetTreeID(), static_text_data_2.id, 1 /* text_offset */,
1946 EXPECT_TRUE(text_position10->AtEndOfParagraph());
1947 EXPECT_FALSE(text_position10->AtStartOfParagraph());
1948
1950 GetTreeID(), preserved_newline_data.id, 0 /* text_offset */,
1952 EXPECT_FALSE(text_position11->AtEndOfParagraph());
1953 EXPECT_FALSE(text_position11->AtStartOfParagraph());
1954
1956 GetTreeID(), preserved_newline_data.id, 1 /* text_offset */,
1958 EXPECT_TRUE(text_position12->AtEndOfParagraph());
1959 EXPECT_FALSE(text_position12->AtStartOfParagraph());
1960
1962 GetTreeID(), more_text_data.id, 0 /* text_offset */,
1964 EXPECT_FALSE(text_position13->AtEndOfParagraph());
1965 EXPECT_TRUE(text_position13->AtStartOfParagraph());
1966
1968 GetTreeID(), more_text_data.id, 1 /* text_offset */,
1970 EXPECT_FALSE(text_position14->AtEndOfParagraph());
1971 EXPECT_FALSE(text_position14->AtStartOfParagraph());
1972}

◆ TEST_F() [291/325]

ui::TEST_F ( AXPositionTest  ,
PreviousParagraphEndStopAtAnchorBoundaryWithConsecutiveParentChildLineBreakingObjects   
)

Definition at line 1974 of file ax_node_position_unittest.cc.

1976 {
1977 // This test updates the tree structure to test a specific edge case -
1978 // CreatePreviousParagraphEndPosition(), stopping at an anchor boundary,
1979 // with consecutive parent-child line breaking objects.
1980 // ++1 rootWebArea
1981 // ++++2 staticText name="first"
1982 // ++++3 genericContainer isLineBreakingObject
1983 // ++++++4 genericContainer isLineBreakingObject
1984 // ++++++5 staticText name="second"
1985 AXNodeData root_data;
1986 root_data.id = 1;
1988
1989 AXNodeData static_text_data_a;
1990 static_text_data_a.id = 2;
1991 static_text_data_a.role = ax::mojom::Role::kStaticText;
1992 static_text_data_a.SetName("first");
1993
1994 AXNodeData container_data_a;
1995 container_data_a.id = 3;
1996 container_data_a.role = ax::mojom::Role::kGenericContainer;
1997 container_data_a.AddBoolAttribute(
1999
2000 AXNodeData container_data_b;
2001 container_data_b.id = 4;
2002 container_data_b.role = ax::mojom::Role::kGenericContainer;
2003 container_data_b.AddBoolAttribute(
2005
2006 AXNodeData static_text_data_b;
2007 static_text_data_b.id = 5;
2008 static_text_data_b.role = ax::mojom::Role::kStaticText;
2009 static_text_data_b.SetName("second");
2010
2011 root_data.child_ids = {static_text_data_a.id, container_data_a.id};
2012 container_data_a.child_ids = {container_data_b.id, static_text_data_b.id};
2013
2014 SetTree(CreateAXTree({root_data, static_text_data_a, container_data_a,
2015 container_data_b, static_text_data_b}));
2016
2018 GetTreeID(), root_data.id, 11 /* text_offset */,
2020
2021 test_position = test_position->CreatePreviousParagraphEndPosition(
2022 AXBoundaryBehavior::StopAtAnchorBoundary);
2023 EXPECT_TRUE(test_position->IsTextPosition());
2024 EXPECT_EQ(root_data.id, test_position->anchor_id());
2025 EXPECT_EQ(5, test_position->text_offset());
2026}

◆ TEST_F() [292/325]

ui::TEST_F ( AXPositionTest  ,
ReciprocalCreateNextAndPreviousCharacterPosition   
)

Definition at line 6560 of file ax_node_position_unittest.cc.

6560 {
6561 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
6562 GetTreeID(), root_.id, 0 /* child_index */);
6563 TestPositionType text_position = tree_position->AsTextPosition();
6564 ASSERT_NE(nullptr, text_position);
6565 ASSERT_TRUE(text_position->IsTextPosition());
6566
6567 size_t next_character_moves = 0;
6568 while (!text_position->IsNullPosition()) {
6569 TestPositionType moved_position =
6570 text_position->CreateNextCharacterPosition(
6571 AXBoundaryBehavior::CrossBoundary);
6572 ASSERT_NE(nullptr, moved_position);
6573
6574 text_position = std::move(moved_position);
6575 ++next_character_moves;
6576 }
6577
6578 tree_position = AXNodePosition::CreateTreePosition(
6579 GetTreeID(), root_.id, root_.child_ids.size() /* child_index */);
6580 text_position = tree_position->AsTextPosition();
6581 ASSERT_NE(nullptr, text_position);
6582 ASSERT_TRUE(text_position->IsTextPosition());
6583
6584 size_t previous_character_moves = 0;
6585 while (!text_position->IsNullPosition()) {
6586 TestPositionType moved_position =
6587 text_position->CreatePreviousCharacterPosition(
6588 AXBoundaryBehavior::CrossBoundary);
6589 ASSERT_NE(nullptr, moved_position);
6590
6591 text_position = std::move(moved_position);
6592 ++previous_character_moves;
6593 }
6594
6595 EXPECT_EQ(next_character_moves, previous_character_moves);
6596 EXPECT_EQ(strlen(TEXT_VALUE), next_character_moves - 1);
6597}

◆ TEST_F() [293/325]

ui::TEST_F ( AXPositionTest  ,
Serialize   
)

Definition at line 551 of file ax_node_position_unittest.cc.

551 {
552 TestPositionType null_position = AXNodePosition::CreateNullPosition();
553 ASSERT_NE(nullptr, null_position);
554 TestPositionType copy_position =
555 AXNodePosition::Unserialize(null_position->Serialize());
556 ASSERT_NE(nullptr, copy_position);
557 EXPECT_TRUE(copy_position->IsNullPosition());
558
559 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
560 GetTreeID(), root_.id, 1 /* child_index */);
561 ASSERT_NE(nullptr, tree_position);
562 copy_position = AXNodePosition::Unserialize(tree_position->Serialize());
563 ASSERT_NE(nullptr, copy_position);
564 EXPECT_TRUE(copy_position->IsTreePosition());
565 EXPECT_EQ(root_.id, copy_position->anchor_id());
566 EXPECT_EQ(1, copy_position->child_index());
567 EXPECT_EQ(AXNodePosition::INVALID_OFFSET, copy_position->text_offset());
568
569 tree_position = AXNodePosition::CreateTreePosition(
570 GetTreeID(), root_.id, AXNodePosition::BEFORE_TEXT);
571 ASSERT_NE(nullptr, tree_position);
572 copy_position = AXNodePosition::Unserialize(tree_position->Serialize());
573 ASSERT_NE(nullptr, copy_position);
574 EXPECT_TRUE(copy_position->IsTreePosition());
575 EXPECT_EQ(root_.id, copy_position->anchor_id());
576 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, copy_position->child_index());
577 EXPECT_EQ(AXNodePosition::INVALID_OFFSET, copy_position->text_offset());
578
580 GetTreeID(), text_field_.id, 0 /* text_offset */,
582 ASSERT_NE(nullptr, text_position);
583 ASSERT_TRUE(text_position->IsTextPosition());
584 copy_position = AXNodePosition::Unserialize(text_position->Serialize());
585 ASSERT_NE(nullptr, copy_position);
586 EXPECT_TRUE(copy_position->IsTextPosition());
587 EXPECT_EQ(text_field_.id, copy_position->anchor_id());
588 EXPECT_EQ(0, copy_position->text_offset());
589 EXPECT_EQ(ax::mojom::TextAffinity::kUpstream, copy_position->affinity());
590
592 GetTreeID(), text_field_.id, 0 /* text_offset */,
594 ASSERT_NE(nullptr, text_position);
595 ASSERT_TRUE(text_position->IsTextPosition());
596 copy_position = AXNodePosition::Unserialize(text_position->Serialize());
597 ASSERT_NE(nullptr, copy_position);
598 EXPECT_TRUE(copy_position->IsTextPosition());
599 EXPECT_EQ(text_field_.id, copy_position->anchor_id());
600 EXPECT_EQ(0, copy_position->text_offset());
601 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, copy_position->affinity());
602 EXPECT_EQ(AXNodePosition::INVALID_INDEX, copy_position->child_index());
603}

◆ TEST_F() [294/325]

ui::TEST_F ( AXPositionTest  ,
Swap   
)

Definition at line 6966 of file ax_node_position_unittest.cc.

6966 {
6967 TestPositionType null_position1 = AXNodePosition::CreateNullPosition();
6968 ASSERT_NE(nullptr, null_position1);
6969 TestPositionType null_position2 = AXNodePosition::CreateNullPosition();
6970 ASSERT_NE(nullptr, null_position2);
6971
6972 swap(*null_position1, *null_position2);
6973 EXPECT_TRUE(null_position1->IsNullPosition());
6974 EXPECT_TRUE(null_position2->IsNullPosition());
6975
6976 TestPositionType tree_position1 = AXNodePosition::CreateTreePosition(
6977 GetTreeID(), root_.id, 2 /* child_index */);
6978 ASSERT_NE(nullptr, tree_position1);
6979 TestPositionType tree_position2 = AXNodePosition::CreateTreePosition(
6980 GetTreeID(), text_field_.id, 3 /* child_index */);
6981 ASSERT_NE(nullptr, tree_position2);
6982
6983 swap(*tree_position1, *tree_position2);
6984 EXPECT_TRUE(tree_position1->IsTreePosition());
6985 EXPECT_EQ(GetTreeID(), tree_position1->tree_id());
6986 EXPECT_EQ(text_field_.id, tree_position1->anchor_id());
6987 EXPECT_EQ(3, tree_position1->child_index());
6988 EXPECT_TRUE(tree_position1->IsTreePosition());
6989 EXPECT_EQ(GetTreeID(), tree_position2->tree_id());
6990 EXPECT_EQ(root_.id, tree_position2->anchor_id());
6991 EXPECT_EQ(2, tree_position2->child_index());
6992
6993 swap(*tree_position1, *null_position1);
6994 EXPECT_TRUE(tree_position1->IsNullPosition());
6995 EXPECT_TRUE(null_position1->IsTreePosition());
6996 EXPECT_EQ(GetTreeID(), null_position1->tree_id());
6997 EXPECT_EQ(text_field_.id, null_position1->anchor_id());
6998 EXPECT_EQ(3, null_position1->child_index());
6999
7001 GetTreeID(), line_break_.id, 1 /* text_offset */,
7003 ASSERT_NE(nullptr, text_position);
7004
7005 swap(*text_position, *null_position1);
7006 EXPECT_TRUE(null_position1->IsTextPosition());
7007 EXPECT_EQ(GetTreeID(), text_position->tree_id());
7008 EXPECT_EQ(line_break_.id, null_position1->anchor_id());
7009 EXPECT_EQ(1, null_position1->text_offset());
7010 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, null_position1->affinity());
7011 EXPECT_TRUE(text_position->IsTreePosition());
7012 EXPECT_EQ(GetTreeID(), text_position->tree_id());
7013 EXPECT_EQ(text_field_.id, text_position->anchor_id());
7014 EXPECT_EQ(3, text_position->child_index());
7015}

◆ TEST_F() [295/325]

ui::TEST_F ( AXPositionTest  ,
TextNavigationWithCollapsedCombobox   
)

Definition at line 7799 of file ax_node_position_unittest.cc.

7799 {
7800 // On Windows, a <select> element is replaced by a combobox that contains
7801 // an AXMenuListPopup parent of AXMenuListOptions. When the select dropdown is
7802 // collapsed, the subtree of that combobox needs to be hidden and, when
7803 // expanded, it must be accessible in the tree. This test ensures we can't
7804 // navigate into the options of a collapsed menu list popup.
7805 g_ax_embedded_object_behavior = AXEmbeddedObjectBehavior::kExposeCharacter;
7806
7807 // ++1 kRootWebArea
7808 // ++++2 kStaticText "Hi"
7809 // ++++++3 kInlineTextBox "Hi"
7810 // ++++4 kPopUpButton
7811 // ++++++5 kMenuListPopup
7812 // ++++++++6 kMenuListOption "Option"
7813 // ++++7 kStaticText "3.14"
7814 // ++++++8 kInlineTextBox "3.14"
7815 AXNodeData root_1;
7816 AXNodeData static_text_2;
7817 AXNodeData inline_box_3;
7818 AXNodeData popup_button_4;
7819 AXNodeData menu_list_popup_5;
7820 AXNodeData menu_list_option_6;
7821 AXNodeData static_text_7;
7822 AXNodeData inline_box_8;
7823
7824 root_1.id = 1;
7825 static_text_2.id = 2;
7826 inline_box_3.id = 3;
7827 popup_button_4.id = 4;
7828 menu_list_popup_5.id = 5;
7829 menu_list_option_6.id = 6;
7830 static_text_7.id = 7;
7831 inline_box_8.id = 8;
7832
7834 root_1.child_ids = {static_text_2.id, popup_button_4.id, static_text_7.id};
7835
7836 static_text_2.role = ax::mojom::Role::kStaticText;
7837 static_text_2.SetName("Hi");
7838 static_text_2.child_ids = {inline_box_3.id};
7839
7841 inline_box_3.SetName("Hi");
7843 {0});
7845
7846 popup_button_4.role = ax::mojom::Role::kPopUpButton;
7847 popup_button_4.child_ids = {menu_list_popup_5.id};
7848 popup_button_4.AddState(ax::mojom::State::kCollapsed);
7849
7850 menu_list_popup_5.role = ax::mojom::Role::kMenuListPopup;
7851 menu_list_popup_5.child_ids = {menu_list_option_6.id};
7852
7853 menu_list_option_6.role = ax::mojom::Role::kMenuListOption;
7854 menu_list_option_6.SetName("Option");
7855
7856 static_text_7.role = ax::mojom::Role::kStaticText;
7857 static_text_7.SetName("3.14");
7858 static_text_7.child_ids = {inline_box_8.id};
7859
7861 inline_box_8.SetName("3.14");
7863 {0});
7865
7866 SetTree(CreateAXTree({root_1, static_text_2, inline_box_3, popup_button_4,
7867 menu_list_popup_5, menu_list_option_6, static_text_7,
7868 inline_box_8}));
7869
7870 // Collapsed - Forward navigation.
7872 GetTreeID(), inline_box_3.id, 0, ax::mojom::TextAffinity::kDownstream);
7873 ASSERT_NE(nullptr, position);
7874
7875 position = position->CreateNextParagraphStartPosition(
7876 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7877 ASSERT_NE(nullptr, position);
7878 EXPECT_EQ(popup_button_4.id, position->anchor_id());
7879 EXPECT_EQ(0, position->text_offset());
7880
7881 position = position->CreateNextParagraphStartPosition(
7882 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7883 ASSERT_NE(nullptr, position);
7884 EXPECT_EQ(inline_box_8.id, position->anchor_id());
7885 EXPECT_EQ(0, position->text_offset());
7886
7887 // Collapsed - Backward navigation.
7889 GetTreeID(), inline_box_8.id, 4, ax::mojom::TextAffinity::kDownstream);
7890 ASSERT_NE(nullptr, position);
7891
7892 position = position->CreatePreviousParagraphEndPosition(
7893 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7894 ASSERT_NE(nullptr, position);
7895 EXPECT_EQ(popup_button_4.id, position->anchor_id());
7896 // The content of this popup button should be replaced with the empty object
7897 // character of length 1.
7898 EXPECT_EQ(1, position->text_offset());
7899
7900 position = position->CreatePreviousParagraphEndPosition(
7901 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7902 ASSERT_NE(nullptr, position);
7903 EXPECT_EQ(inline_box_3.id, position->anchor_id());
7904 EXPECT_EQ(2, position->text_offset());
7905
7906 // Expand the combobox for the rest of the test.
7908 popup_button_4.AddState(ax::mojom::State::kExpanded);
7910 update.nodes = {popup_button_4};
7911 ASSERT_TRUE(GetTree()->Unserialize(update));
7912
7913 // Expanded - Forward navigation.
7915 GetTreeID(), inline_box_3.id, 0, ax::mojom::TextAffinity::kDownstream);
7916 ASSERT_NE(nullptr, position);
7917
7918 position = position->CreateNextParagraphStartPosition(
7919 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7920 ASSERT_NE(nullptr, position);
7921 EXPECT_EQ(menu_list_option_6.id, position->anchor_id());
7922 EXPECT_EQ(0, position->text_offset());
7923
7924 position = position->CreateNextParagraphStartPosition(
7925 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7926 ASSERT_NE(nullptr, position);
7927 EXPECT_EQ(inline_box_8.id, position->anchor_id());
7928 EXPECT_EQ(0, position->text_offset());
7929
7930 // Expanded- Backward navigation.
7932 GetTreeID(), inline_box_8.id, 4, ax::mojom::TextAffinity::kDownstream);
7933 ASSERT_NE(nullptr, position);
7934
7935 position = position->CreatePreviousParagraphEndPosition(
7936 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7937 ASSERT_NE(nullptr, position);
7938 EXPECT_EQ(menu_list_option_6.id, position->anchor_id());
7939 EXPECT_EQ(1, position->text_offset());
7940
7941 position = position->CreatePreviousParagraphEndPosition(
7942 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7943 ASSERT_NE(nullptr, position);
7944 EXPECT_EQ(inline_box_3.id, position->anchor_id());
7945 EXPECT_EQ(2, position->text_offset());
7946}
void RemoveState(ax::mojom::State state)

◆ TEST_F() [296/325]

ui::TEST_F ( AXPositionTest  ,
ToString   
)

Definition at line 605 of file ax_node_position_unittest.cc.

605 {
606 AXNodeData root_data;
607 root_data.id = 1;
609
610 AXNodeData static_text_data_1;
611 static_text_data_1.id = 2;
612 static_text_data_1.role = ax::mojom::Role::kStaticText;
613 static_text_data_1.SetName("some text");
614
615 AXNodeData static_text_data_2;
616 static_text_data_2.id = 3;
617 static_text_data_2.role = ax::mojom::Role::kStaticText;
618 static_text_data_2.SetName(u"\xfffc");
619
620 AXNodeData static_text_data_3;
621 static_text_data_3.id = 4;
622 static_text_data_3.role = ax::mojom::Role::kStaticText;
623 static_text_data_3.SetName("more text");
624
625 root_data.child_ids = {static_text_data_1.id, static_text_data_2.id,
626 static_text_data_3.id};
627
628 SetTree(CreateAXTree(
629 {root_data, static_text_data_1, static_text_data_2, static_text_data_3}));
630
632 GetTreeID(), root_data.id, 0 /* text_offset */,
634 ASSERT_TRUE(text_position_1->IsTextPosition());
635 EXPECT_EQ(
636 "TextPosition anchor_id=1 text_offset=0 affinity=downstream "
637 "annotated_text=<s>ome text\xEF\xBF\xBCmore text",
638 text_position_1->ToString());
639
641 GetTreeID(), root_data.id, 5 /* text_offset */,
643 ASSERT_TRUE(text_position_2->IsTextPosition());
644 EXPECT_EQ(
645 "TextPosition anchor_id=1 text_offset=5 affinity=downstream "
646 "annotated_text=some <t>ext\xEF\xBF\xBCmore text",
647 text_position_2->ToString());
648
650 GetTreeID(), root_data.id, 9 /* text_offset */,
652 ASSERT_TRUE(text_position_3->IsTextPosition());
653 EXPECT_EQ(
654 "TextPosition anchor_id=1 text_offset=9 affinity=downstream "
655 "annotated_text=some text<\xEF\xBF\xBC>more text",
656 text_position_3->ToString());
657
659 GetTreeID(), root_data.id, 10 /* text_offset */,
661 ASSERT_TRUE(text_position_4->IsTextPosition());
662 EXPECT_EQ(
663 "TextPosition anchor_id=1 text_offset=10 affinity=downstream "
664 "annotated_text=some text\xEF\xBF\xBC<m>ore text",
665 text_position_4->ToString());
666
668 GetTreeID(), root_data.id, 19 /* text_offset */,
670 ASSERT_TRUE(text_position_5->IsTextPosition());
671 EXPECT_EQ(
672 "TextPosition anchor_id=1 text_offset=19 affinity=downstream "
673 "annotated_text=some text\xEF\xBF\xBCmore text<>",
674 text_position_5->ToString());
675
677 GetTreeID(), static_text_data_2.id, 0 /* text_offset */,
679 ASSERT_TRUE(text_position_6->IsTextPosition());
680 EXPECT_EQ(
681 "TextPosition anchor_id=3 text_offset=0 affinity=downstream "
682 "annotated_text=<\xEF\xBF\xBC>",
683 text_position_6->ToString());
684
686 GetTreeID(), static_text_data_2.id, 1 /* text_offset */,
688 ASSERT_TRUE(text_position_7->IsTextPosition());
689 EXPECT_EQ(
690 "TextPosition anchor_id=3 text_offset=1 affinity=downstream "
691 "annotated_text=\xEF\xBF\xBC<>",
692 text_position_7->ToString());
693
695 GetTreeID(), static_text_data_3.id, 0 /* text_offset */,
697 ASSERT_TRUE(text_position_8->IsTextPosition());
698 EXPECT_EQ(
699 "TextPosition anchor_id=4 text_offset=0 affinity=downstream "
700 "annotated_text=<m>ore text",
701 text_position_8->ToString());
702
704 GetTreeID(), static_text_data_3.id, 5 /* text_offset */,
706 ASSERT_TRUE(text_position_9->IsTextPosition());
707 EXPECT_EQ(
708 "TextPosition anchor_id=4 text_offset=5 affinity=downstream "
709 "annotated_text=more <t>ext",
710 text_position_9->ToString());
711
713 GetTreeID(), static_text_data_3.id, 9 /* text_offset */,
715 ASSERT_TRUE(text_position_10->IsTextPosition());
716 EXPECT_EQ(
717 "TextPosition anchor_id=4 text_offset=9 affinity=downstream "
718 "annotated_text=more text<>",
719 text_position_10->ToString());
720}

◆ TEST_F() [297/325]

ui::TEST_F ( AXRangeTest  ,
AsForwardRange   
)

Definition at line 369 of file ax_range_unittest.cc.

369 {
370 TestPositionRange null_range(AXNodePosition::CreateNullPosition(),
371 AXNodePosition::CreateNullPosition());
372 null_range = null_range.AsForwardRange();
373 EXPECT_TRUE(null_range.IsNull());
374
375 TestPositionInstance tree_position = AXNodePosition::CreateTreePosition(
376 GetTreeID(), button_.id, 0 /* child_index */);
378 GetTreeID(), line_break1_.id, 1 /* text_offset */,
381 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
383
384 TestPositionRange tree_to_text_range(text_position1->Clone(),
385 tree_position->Clone());
386 tree_to_text_range = tree_to_text_range.AsForwardRange();
387 EXPECT_EQ(*tree_position, *tree_to_text_range.anchor());
388 EXPECT_EQ(*text_position1, *tree_to_text_range.focus());
389
390 TestPositionRange text_to_text_range(text_position2->Clone(),
391 text_position1->Clone());
392 text_to_text_range = text_to_text_range.AsForwardRange();
393 EXPECT_EQ(*text_position1, *text_to_text_range.anchor());
394 EXPECT_EQ(*text_position2, *text_to_text_range.focus());
395}
std::unique_ptr< AXPosition< AXNodePosition, AXNode > > TestPositionInstance

◆ TEST_F() [298/325]

ui::TEST_F ( AXRangeTest  ,
BeginAndEndIterators   
)

Definition at line 463 of file ax_range_unittest.cc.

463 {
464 TestPositionInstance null_position = AXNodePosition::CreateNullPosition();
466 GetTreeID(), button_.id, 3 /* text_offset */,
469 GetTreeID(), check_box1_.id, 0 /* text_offset */,
472 GetTreeID(), check_box2_.id, 0 /* text_offset */,
475 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
477
478 TestPositionRange nullptr_and_null_position(nullptr, null_position->Clone());
479 EXPECT_EQ(TestPositionRange::Iterator(), nullptr_and_null_position.begin());
480 EXPECT_EQ(TestPositionRange::Iterator(), nullptr_and_null_position.end());
481
482 TestPositionRange test_position1_and_nullptr(test_position1->Clone(),
483 nullptr);
484 EXPECT_EQ(TestPositionRange::Iterator(), test_position1_and_nullptr.begin());
485 EXPECT_EQ(TestPositionRange::Iterator(), test_position1_and_nullptr.end());
486
487 TestPositionRange null_position_and_test_position2(null_position->Clone(),
488 test_position2->Clone());
489 EXPECT_EQ(TestPositionRange::Iterator(),
490 null_position_and_test_position2.begin());
491 EXPECT_EQ(TestPositionRange::Iterator(),
492 null_position_and_test_position2.end());
493
494 TestPositionRange test_position1_and_test_position2(test_position1->Clone(),
495 test_position2->Clone());
496 EXPECT_NE(TestPositionRange::Iterator(test_position1->Clone(),
497 test_position4->Clone()),
498 test_position1_and_test_position2.begin());
499 EXPECT_NE(TestPositionRange::Iterator(test_position1->Clone(),
500 test_position3->Clone()),
501 test_position1_and_test_position2.begin());
502 EXPECT_EQ(TestPositionRange::Iterator(test_position1->Clone(),
503 test_position2->Clone()),
504 test_position1_and_test_position2.begin());
505 EXPECT_EQ(TestPositionRange::Iterator(nullptr, test_position2->Clone()),
506 test_position1_and_test_position2.end());
507
508 TestPositionRange test_position3_and_test_position4(test_position3->Clone(),
509 test_position4->Clone());
510 EXPECT_NE(TestPositionRange::Iterator(test_position1->Clone(),
511 test_position4->Clone()),
512 test_position3_and_test_position4.begin());
513 EXPECT_NE(TestPositionRange::Iterator(test_position2->Clone(),
514 test_position4->Clone()),
515 test_position3_and_test_position4.begin());
516 EXPECT_EQ(TestPositionRange::Iterator(test_position3->Clone(),
517 test_position4->Clone()),
518 test_position3_and_test_position4.begin());
519 EXPECT_NE(TestPositionRange::Iterator(nullptr, test_position2->Clone()),
520 test_position3_and_test_position4.end());
521 EXPECT_NE(TestPositionRange::Iterator(nullptr, test_position3->Clone()),
522 test_position3_and_test_position4.end());
523 EXPECT_EQ(TestPositionRange::Iterator(nullptr, test_position4->Clone()),
524 test_position3_and_test_position4.end());
525}

◆ TEST_F() [299/325]

ui::TEST_F ( AXRangeTest  ,
EqualityOperators   
)

Definition at line 329 of file ax_range_unittest.cc.

329 {
330 TestPositionInstance null_position = AXNodePosition::CreateNullPosition();
332 GetTreeID(), button_.id, 0 /* text_offset */,
335 GetTreeID(), line_break1_.id, 1 /* text_offset */,
338 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
340
341 // Invalid ranges (with at least one null endpoint).
342 TestPositionRange null_position_and_nullptr(null_position->Clone(), nullptr);
343 TestPositionRange nullptr_and_test_position(nullptr, test_position1->Clone());
344 TestPositionRange test_position_and_null_position(test_position2->Clone(),
345 null_position->Clone());
346
347 TestPositionRange test_positions_1_and_2(test_position1->Clone(),
348 test_position2->Clone());
349 TestPositionRange test_positions_2_and_1(test_position2->Clone(),
350 test_position1->Clone());
351 TestPositionRange test_positions_1_and_3(test_position1->Clone(),
352 test_position3->Clone());
353 TestPositionRange test_positions_2_and_3(test_position2->Clone(),
354 test_position3->Clone());
355 TestPositionRange test_positions_3_and_2(test_position3->Clone(),
356 test_position2->Clone());
357
358 EXPECT_EQ(null_position_and_nullptr, nullptr_and_test_position);
359 EXPECT_EQ(nullptr_and_test_position, test_position_and_null_position);
360 EXPECT_NE(null_position_and_nullptr, test_positions_2_and_1);
361 EXPECT_NE(test_positions_2_and_1, test_position_and_null_position);
362 EXPECT_EQ(test_positions_1_and_2, test_positions_1_and_2);
363 EXPECT_NE(test_positions_2_and_1, test_positions_1_and_2);
364 EXPECT_EQ(test_positions_3_and_2, test_positions_2_and_3);
365 EXPECT_NE(test_positions_1_and_2, test_positions_2_and_3);
366 EXPECT_EQ(test_positions_1_and_2, test_positions_1_and_3);
367}

◆ TEST_F() [300/325]

ui::TEST_F ( AXRangeTest  ,
GetRects   
)

Definition at line 1161 of file ax_range_unittest.cc.

1161 {
1162 TestAXRangeScreenRectDelegate delegate(this);
1163
1164 // Setting up ax ranges for testing.
1166 GetTreeID(), button_.id, 0 /* text_offset */,
1168
1170 GetTreeID(), check_box1_.id, 0 /* text_offset */,
1173 GetTreeID(), check_box2_.id, 0 /* text_offset */,
1175
1177 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
1180 GetTreeID(), inline_box1_.id, 1 /* text_offset */,
1183 GetTreeID(), inline_box1_.id, 3 /* text_offset */,
1185 TestPositionInstance line1_second_to_last_char =
1186 AXNodePosition::CreateTextPosition(GetTreeID(), inline_box1_.id,
1187 5 /* text_offset */,
1190 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
1192
1194 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
1197 GetTreeID(), inline_box2_.id, 1 /* text_offset */,
1200 GetTreeID(), inline_box2_.id, 3 /* text_offset */,
1202 TestPositionInstance line2_second_to_last_char =
1203 AXNodePosition::CreateTextPosition(GetTreeID(), inline_box2_.id,
1204 5 /* text_offset */,
1207 GetTreeID(), inline_box2_.id, 6 /* text_offset */,
1209
1211 GetTreeID(), inline_box3_.id, 5 /* text_offset */,
1213
1214 // Since a button is not visible to the text representation, it spans an
1215 // empty anchor whose start and end positions are the same.
1216 TestPositionRange button_range(button->Clone(), button->Clone());
1217 std::vector<gfx::Rect> expected_screen_rects = {gfx::Rect(20, 20, 100, 30)};
1219 ContainerEQ(button_range.GetRects(&delegate), expected_screen_rects));
1220
1221 // Since a check box is not visible to the text representation, it spans an
1222 // empty anchor whose start and end positions are the same.
1223 TestPositionRange check_box1_range(check_box1->Clone(), check_box1->Clone());
1224 expected_screen_rects = {gfx::Rect(120, 20, 30, 30)};
1226 ContainerEQ(check_box1_range.GetRects(&delegate), expected_screen_rects));
1227
1228 // Retrieving bounding boxes of the button and both checkboxes.
1229 TestPositionRange button_check_box2_range(button->Clone(),
1230 check_box2->Clone());
1231 expected_screen_rects = {gfx::Rect(20, 20, 100, 30),
1232 gfx::Rect(120, 20, 30, 30),
1233 gfx::Rect(150, 20, 30, 30)};
1234 EXPECT_TRUE(ContainerEQ(button_check_box2_range.GetRects(&delegate),
1235 expected_screen_rects));
1236
1237 // Retrieving bounding box of text line 1, its whole range.
1238 // 0 1 2 3 4 5
1239 // |L|i|n|e| |1|
1240 // |-----------|
1241 TestPositionRange line1_whole_range(line1_start->Clone(), line1_end->Clone());
1242 expected_screen_rects = {gfx::Rect(20, 50, 30, 30)};
1243 EXPECT_TRUE(ContainerEQ(line1_whole_range.GetRects(&delegate),
1244 expected_screen_rects));
1245
1246 // Retrieving bounding box of text line 1, its first half range.
1247 // 0 1 2 3 4 5
1248 // |L|i|n|e| |1|
1249 // |-----|
1250 TestPositionRange line1_first_half_range(line1_start->Clone(),
1251 line1_middle->Clone());
1252 expected_screen_rects = {gfx::Rect(20, 50, 15, 30)};
1253 EXPECT_TRUE(ContainerEQ(line1_first_half_range.GetRects(&delegate),
1254 expected_screen_rects));
1255
1256 // Retrieving bounding box of text line 1, its second half range.
1257 // 0 1 2 3 4 5
1258 // |L|i|n|e| |1|
1259 // |-----|
1260 TestPositionRange line1_second_half_range(line1_middle->Clone(),
1261 line1_end->Clone());
1262 expected_screen_rects = {gfx::Rect(35, 50, 15, 30)};
1263 EXPECT_TRUE(ContainerEQ(line1_second_half_range.GetRects(&delegate),
1264 expected_screen_rects));
1265
1266 // Retrieving bounding box of text line 1, its mid range.
1267 // 0 1 2 3 4 5
1268 // |L|i|n|e| |1|
1269 // |-------|
1270 TestPositionRange line1_mid_range(line1_second_char->Clone(),
1271 line1_second_to_last_char->Clone());
1272 expected_screen_rects = {gfx::Rect(25, 50, 20, 30)};
1274 ContainerEQ(line1_mid_range.GetRects(&delegate), expected_screen_rects));
1275
1276 // Retrieving bounding box of text line 2, its whole range.
1277 // 0 1 2 3 4 5
1278 // |L|i|n|e| |2|
1279 // |-----------|
1280 TestPositionRange line2_whole_range(line2_start->Clone(), line2_end->Clone());
1281 expected_screen_rects = {gfx::Rect(20, 80, 42, 30)};
1282 EXPECT_TRUE(ContainerEQ(line2_whole_range.GetRects(&delegate),
1283 expected_screen_rects));
1284
1285 // Retrieving bounding box of text line 2, its first half range.
1286 // 0 1 2 3 4 5
1287 // |L|i|n|e| |2|
1288 // |-----|
1289 TestPositionRange line2_first_half_range(line2_start->Clone(),
1290 line2_middle->Clone());
1291 expected_screen_rects = {gfx::Rect(20, 80, 21, 30)};
1292 EXPECT_TRUE(ContainerEQ(line2_first_half_range.GetRects(&delegate),
1293 expected_screen_rects));
1294
1295 // Retrieving bounding box of text line 2, its second half range.
1296 // 0 1 2 3 4 5
1297 // |L|i|n|e| |2|
1298 // |-----|
1299 TestPositionRange line2_second_half_range(line2_middle->Clone(),
1300 line2_end->Clone());
1301 expected_screen_rects = {gfx::Rect(41, 80, 21, 30)};
1302 EXPECT_TRUE(ContainerEQ(line2_second_half_range.GetRects(&delegate),
1303 expected_screen_rects));
1304
1305 // Retrieving bounding box of text line 2, its mid range.
1306 // 0 1 2 3 4 5
1307 // |L|i|n|e| |2|
1308 // |-------|
1309 TestPositionRange line2_mid_range(line2_second_char->Clone(),
1310 line2_second_to_last_char->Clone());
1311 expected_screen_rects = {gfx::Rect(27, 80, 28, 30)};
1313 ContainerEQ(line2_mid_range.GetRects(&delegate), expected_screen_rects));
1314
1315 // Retrieving bounding boxes of text line 1 and line 2, the entire range.
1316 // |L|i|n|e| |1|\n|L|i|n|e| |2|\n|
1317 // |--------------------------|
1318 TestPositionRange line1_line2_whole_range(line1_start->Clone(),
1319 line2_end->Clone());
1320 expected_screen_rects = {gfx::Rect(20, 50, 30, 30),
1321 gfx::Rect(20, 80, 42, 30)};
1322 EXPECT_TRUE(ContainerEQ(line1_line2_whole_range.GetRects(&delegate),
1323 expected_screen_rects));
1324
1325 // Retrieving bounding boxes of the range that spans from the middle of text
1326 // line 1 to the middle of text line 2.
1327 // |L|i|n|e| |1|\n|L|i|n|e| |2|\n|
1328 // |--------------|
1329 TestPositionRange line1_line2_mid_range(line1_middle->Clone(),
1330 line2_middle->Clone());
1331 expected_screen_rects = {gfx::Rect(35, 50, 15, 30),
1332 gfx::Rect(20, 80, 21, 30)};
1333 EXPECT_TRUE(ContainerEQ(line1_line2_mid_range.GetRects(&delegate),
1334 expected_screen_rects));
1335
1336 // Retrieving bounding boxes of the range that spans from the checkbox 2
1337 // ("invisible" in the text representation) to the middle of text line 2.
1338 // |[Button][Checkbox 1][Checkbox 2]L|i|n|e| |1|\n|L|i|n|e| |2|\n|A|f|t|e|r|
1339 // |-------------------------------|
1340 TestPositionRange check_box2_line2_mid_range(check_box2->Clone(),
1341 line2_middle->Clone());
1342 expected_screen_rects = {gfx::Rect(150, 20, 30, 30),
1343 gfx::Rect(20, 50, 30, 30),
1344 gfx::Rect(20, 80, 21, 30)};
1345 EXPECT_TRUE(ContainerEQ(check_box2_line2_mid_range.GetRects(&delegate),
1346 expected_screen_rects));
1347
1348 // Retrieving bounding boxes of the range spanning the entire document.
1349 // |[Button][Checkbox 1][Checkbox 2]L|i|n|e| |1|\n|L|i|n|e| |2|\n|A|f|t|e|r|
1350 // |-----------------------------------------------------------------------|
1351 TestPositionRange entire_test_range(button->Clone(), after_line_end->Clone());
1352 expected_screen_rects = {
1353 gfx::Rect(20, 20, 100, 30), gfx::Rect(120, 20, 30, 30),
1354 gfx::Rect(150, 20, 30, 30), gfx::Rect(20, 50, 30, 30),
1355 gfx::Rect(20, 80, 42, 30), gfx::Rect(20, 110, 50, 30)};
1356 EXPECT_TRUE(ContainerEQ(entire_test_range.GetRects(&delegate),
1357 expected_screen_rects));
1358}
TRect< Scalar > Rect
Definition: rect.h:769
AXRange< AXPosition< AXNodePosition, AXNode > > TestPositionRange

◆ TEST_F() [301/325]

ui::TEST_F ( AXRangeTest  ,
GetRectsOffscreen   
)

Definition at line 1360 of file ax_range_unittest.cc.

1360 {
1361 // Set up root node bounds/viewport size to {0, 50, 800x60}, so that only
1362 // some text will be onscreen the rest will be offscreen.
1363 AXNodeData old_root_node_data = GetRootAsAXNode()->data();
1364 AXNodeData new_root_node_data = old_root_node_data;
1365 new_root_node_data.relative_bounds.bounds = gfx::RectF(0, 50, 800, 60);
1366 GetRootAsAXNode()->SetData(new_root_node_data);
1367
1368 TestAXRangeScreenRectDelegate delegate(this);
1369
1371 GetTreeID(), button_.id, 0 /* text_offset */,
1373
1375 GetTreeID(), inline_box3_.id, 5 /* text_offset */,
1377
1378 // [Button] [Checkbox 1] [Checkbox 2]
1379 // {20, 20, 100x30}, {120, 20, 30x30} {150, 20, 30x30}
1380 // ---
1381 // [Line 1] |
1382 // {20, 50, 30x30} | view port, onscreen
1383 // | {0, 50, 800x60}
1384 // [Line 2] |
1385 // {20, 80, 42x30} |
1386 // ---
1387 // [After]
1388 // {20, 110, 50x30}
1389 //
1390 // Retrieving bounding boxes of the range spanning the entire document.
1391 // |[Button][Checkbox 1][Checkbox 2]L|i|n|e| |1|\n|L|i|n|e| |2|\n|A|f|t|e|r|
1392 // |-----------------------------------------------------------------------|
1393 TestPositionRange entire_test_range(button->Clone(), after_line_end->Clone());
1394 std::vector<gfx::Rect> expected_screen_rects = {gfx::Rect(20, 50, 30, 30),
1395 gfx::Rect(20, 80, 42, 30)};
1396 EXPECT_TRUE(ContainerEQ(entire_test_range.GetRects(&delegate),
1397 expected_screen_rects));
1398
1399 // Reset the root node bounds/viewport size back to {0, 0, 800x600}, and
1400 // verify all elements should be onscreen.
1401 GetRootAsAXNode()->SetData(old_root_node_data);
1402 expected_screen_rects = {
1403 gfx::Rect(20, 20, 100, 30), gfx::Rect(120, 20, 30, 30),
1404 gfx::Rect(150, 20, 30, 30), gfx::Rect(20, 50, 30, 30),
1405 gfx::Rect(20, 80, 42, 30), gfx::Rect(20, 110, 50, 30)};
1406 EXPECT_TRUE(ContainerEQ(entire_test_range.GetRects(&delegate),
1407 expected_screen_rects));
1408}

◆ TEST_F() [302/325]

ui::TEST_F ( AXRangeTest  ,
GetTextAddingNewlineBetweenParagraphs   
)

Definition at line 913 of file ax_range_unittest.cc.

913 {
915 GetTreeID(), button_.id, 0 /* text_offset */,
918 GetTreeID(), button_.id, 6 /* text_offset */,
920
922 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
925 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
927
929 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
932 GetTreeID(), inline_box2_.id, 6 /* text_offset */,
934
936 GetTreeID(), inline_box3_.id, 0 /* text_offset */,
939 GetTreeID(), inline_box3_.id, 5 /* text_offset */,
941
942 auto TestGetTextForRange = [](TestPositionInstance range_start,
943 TestPositionInstance range_end,
944 const std::u16string& expected_text,
945 const size_t expected_appended_newlines_count) {
946 TestPositionRange forward_test_range(range_start->Clone(),
947 range_end->Clone());
948 TestPositionRange backward_test_range(std::move(range_end),
949 std::move(range_start));
950 size_t appended_newlines_count = 0;
951 EXPECT_EQ(expected_text, forward_test_range.GetText(
952 AXTextConcatenationBehavior::kAsInnerText, -1,
953 false, &appended_newlines_count));
954 EXPECT_EQ(expected_appended_newlines_count, appended_newlines_count);
955 EXPECT_EQ(expected_text, backward_test_range.GetText(
956 AXTextConcatenationBehavior::kAsInnerText, -1,
957 false, &appended_newlines_count));
958 EXPECT_EQ(expected_appended_newlines_count, appended_newlines_count);
959 };
960
961 std::u16string button_start_to_line1_end =
962 BUTTON.substr().append(NEWLINE).append(LINE_1);
963 TestGetTextForRange(button_start->Clone(), line1_end->Clone(),
964 button_start_to_line1_end, 1);
965 std::u16string button_start_to_line1_start = BUTTON.substr().append(NEWLINE);
966 TestGetTextForRange(button_start->Clone(), line1_start->Clone(),
967 button_start_to_line1_start, 1);
968 std::u16string button_end_to_line1_end = NEWLINE.substr().append(LINE_1);
969 TestGetTextForRange(button_end->Clone(), line1_end->Clone(),
970 button_end_to_line1_end, 1);
971 std::u16string button_end_to_line1_start = NEWLINE;
972 TestGetTextForRange(button_end->Clone(), line1_start->Clone(),
973 button_end_to_line1_start, 1);
974
975 std::u16string line2_start_to_after_line_end =
976 LINE_2.substr().append(NEWLINE).append(AFTER_LINE);
977 TestGetTextForRange(line2_start->Clone(), after_line_end->Clone(),
978 line2_start_to_after_line_end, 0);
979 std::u16string line2_start_to_after_line_start =
980 LINE_2.substr().append(NEWLINE);
981 TestGetTextForRange(line2_start->Clone(), after_line_start->Clone(),
982 line2_start_to_after_line_start, 0);
983 std::u16string line2_end_to_after_line_end =
984 NEWLINE.substr().append(AFTER_LINE);
985 TestGetTextForRange(line2_end->Clone(), after_line_end->Clone(),
986 line2_end_to_after_line_end, 0);
987 std::u16string line2_end_to_after_line_start = NEWLINE;
988 TestGetTextForRange(line2_end->Clone(), after_line_start->Clone(),
989 line2_end_to_after_line_start, 0);
990
991 std::u16string all_text =
992 BUTTON.substr().append(NEWLINE).append(TEXT_FIELD).append(AFTER_LINE);
994 GetTreeID(), root_.id, 0 /* text_offset */,
997 GetTreeID(), root_.id, ALL_TEXT.length() /* text_offset */,
999 TestGetTextForRange(std::move(start), std::move(end), all_text, 1);
1000}

◆ TEST_F() [303/325]

ui::TEST_F ( AXRangeTest  ,
GetTextWithEmptyRanges   
)

Definition at line 856 of file ax_range_unittest.cc.

856 {
857 // empty string with non-leaf tree position
858 TestPositionInstance start = AXNodePosition::CreateTreePosition(
859 GetTreeID(), root_.id, 0 /* child_index */);
860 TestPositionRange non_leaf_tree_range(start->Clone(), start->Clone());
861 EXPECT_EQ(EMPTY, non_leaf_tree_range.GetText());
862
863 // empty string with leaf tree position
864 start = AXNodePosition::CreateTreePosition(GetTreeID(), inline_box1_.id,
865 0 /* child_index */);
866 TestPositionRange leaf_empty_range(start->Clone(), start->Clone());
867 EXPECT_EQ(EMPTY, leaf_empty_range.GetText());
868
869 // empty string with leaf text position and no offset
871 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
873 TestPositionRange leaf_text_no_offset(start->Clone(), start->Clone());
874 EXPECT_EQ(EMPTY, leaf_text_no_offset.GetText());
875
876 // empty string with leaf text position with offset
878 GetTreeID(), inline_box1_.id, 3 /* text_offset */,
880 TestPositionRange leaf_text_offset(start->Clone(), start->Clone());
881 EXPECT_EQ(EMPTY, leaf_text_offset.GetText());
882
883 // empty string with non-leaf text with no offset
885 GetTreeID(), root_.id, 0 /* text_offset */,
887 TestPositionRange non_leaf_text_no_offset(start->Clone(), start->Clone());
888 EXPECT_EQ(EMPTY, non_leaf_text_no_offset.GetText());
889
890 // empty string with non-leaf text position with offset
892 GetTreeID(), root_.id, 3 /* text_offset */,
894 TestPositionRange non_leaf_text_offset(start->Clone(), start->Clone());
895 EXPECT_EQ(EMPTY, non_leaf_text_offset.GetText());
896
897 // empty string with same position between two anchors, but different offsets
899 GetTreeID(), line_break1_.id, 1 /* text_offset */,
902 GetTreeID(), static_text2_.id, 0 /* text_offset */,
904
905 TestPositionRange same_position_different_anchors_forward(
906 after_end->Clone(), before_start->Clone());
907 EXPECT_EQ(EMPTY, same_position_different_anchors_forward.GetText());
908 TestPositionRange same_position_different_anchors_backward(
909 before_start->Clone(), after_end->Clone());
910 EXPECT_EQ(EMPTY, same_position_different_anchors_backward.GetText());
911}

◆ TEST_F() [304/325]

ui::TEST_F ( AXRangeTest  ,
GetTextWithList   
)

Definition at line 1023 of file ax_range_unittest.cc.

1023 {
1024 const std::u16string kListMarker1 = base::ASCIIToUTF16("1. ");
1025 const std::u16string kListItemContent = base::ASCIIToUTF16("List item 1");
1026 const std::u16string kListMarker2 = base::ASCIIToUTF16("2. ");
1027 const std::u16string kAfterList = base::ASCIIToUTF16("After list");
1028 const std::u16string kAllText = kListMarker1.substr()
1029 .append(kListItemContent)
1030 .append(NEWLINE)
1031 .append(kListMarker2)
1032 .append(NEWLINE)
1033 .append(kAfterList);
1034 // This test expects:
1035 // "1. List item 1
1036 // 2.
1037 // After list"
1038 // for the following AXTree:
1039 // ++1 kRootWebArea
1040 // ++++2 kList
1041 // ++++++3 kListItem
1042 // ++++++++4 kListMarker
1043 // ++++++++++5 kStaticText
1044 // ++++++++++++6 kInlineTextBox "1. "
1045 // ++++++++7 kStaticText
1046 // ++++++++++8 kInlineTextBox "List item 1"
1047 // ++++++9 kListItem
1048 // ++++++++10 kListMarker
1049 // +++++++++++11 kStaticText
1050 // ++++++++++++++12 kInlineTextBox "2. "
1051 // ++++13 kStaticText
1052 // +++++++14 kInlineTextBox "After list"
1054 AXNodeData list;
1055 AXNodeData list_item1;
1056 AXNodeData list_item2;
1057 AXNodeData list_marker1;
1058 AXNodeData list_marker2;
1059 AXNodeData inline_box1;
1060 AXNodeData inline_box2;
1061 AXNodeData inline_box3;
1062 AXNodeData inline_box4;
1063 AXNodeData static_text1;
1064 AXNodeData static_text2;
1065 AXNodeData static_text3;
1066 AXNodeData static_text4;
1067
1068 root.id = 1;
1069 list.id = 2;
1070 list_item1.id = 3;
1071 list_marker1.id = 4;
1072 static_text1.id = 5;
1073 inline_box1.id = 6;
1074 static_text2.id = 7;
1075 inline_box2.id = 8;
1076 list_item2.id = 9;
1077 list_marker2.id = 10;
1078 static_text3.id = 11;
1079 inline_box3.id = 12;
1080 static_text4.id = 13;
1081 inline_box4.id = 14;
1082
1084 root.child_ids = {list.id, static_text4.id};
1085
1087 list.child_ids = {list_item1.id, list_item2.id};
1088
1089 list_item1.role = ax::mojom::Role::kListItem;
1090 list_item1.child_ids = {list_marker1.id, static_text2.id};
1092 true);
1093
1094 list_marker1.role = ax::mojom::Role::kListMarker;
1095 list_marker1.child_ids = {static_text1.id};
1096
1097 static_text1.role = ax::mojom::Role::kStaticText;
1098 static_text1.SetName(kListMarker1);
1099 static_text1.child_ids = {inline_box1.id};
1100
1102 inline_box1.SetName(kListMarker1);
1103
1104 static_text2.role = ax::mojom::Role::kStaticText;
1105 static_text2.SetName(kListItemContent);
1106 static_text2.child_ids = {inline_box2.id};
1107
1109 inline_box2.SetName(kListItemContent);
1110
1111 list_item2.role = ax::mojom::Role::kListItem;
1112 list_item2.child_ids = {list_marker2.id};
1114 true);
1115
1116 list_marker2.role = ax::mojom::Role::kListMarker;
1117 list_marker2.child_ids = {static_text3.id};
1118
1119 static_text3.role = ax::mojom::Role::kStaticText;
1120 static_text3.SetName(kListMarker2);
1121 static_text3.child_ids = {inline_box3.id};
1122
1124 inline_box3.SetName(kListMarker2);
1125
1126 static_text4.role = ax::mojom::Role::kStaticText;
1127 static_text4.SetName(kAfterList);
1128 static_text4.child_ids = {inline_box4.id};
1129
1131 inline_box4.SetName(kAfterList);
1132
1133 AXTreeUpdate initial_state;
1134 initial_state.root_id = root.id;
1135 initial_state.nodes = {root, list, list_item1, list_marker1,
1136 static_text1, inline_box1, static_text2, inline_box2,
1137 list_item2, list_marker2, static_text3, inline_box3,
1138 static_text4, inline_box4};
1139 initial_state.has_tree_data = true;
1140 initial_state.tree_data.tree_id = AXTreeID::CreateNewAXTreeID();
1141 initial_state.tree_data.title = "Dialog title";
1142
1143 SetTree(std::make_unique<AXTree>(initial_state));
1144
1146 GetTreeID(), inline_box1.id, 0 /* text_offset */,
1148 ASSERT_TRUE(start->IsTextPosition());
1150 GetTreeID(), inline_box4.id, 10 /* text_offset */,
1152 ASSERT_TRUE(end->IsTextPosition());
1153 TestPositionRange forward_range(start->Clone(), end->Clone());
1154 EXPECT_EQ(kAllText,
1155 forward_range.GetText(AXTextConcatenationBehavior::kAsInnerText));
1156 TestPositionRange backward_range(std::move(end), std::move(start));
1157 EXPECT_EQ(kAllText,
1158 backward_range.GetText(AXTextConcatenationBehavior::kAsInnerText));
1159}
std::u16string ASCIIToUTF16(std::string src)
Definition: string_utils.cc:63

◆ TEST_F() [305/325]

ui::TEST_F ( AXRangeTest  ,
GetTextWithMaxCount   
)

Definition at line 1002 of file ax_range_unittest.cc.

1002 {
1004 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
1007 GetTreeID(), inline_box2_.id, 6 /* text_offset */,
1009
1010 TestPositionRange test_range(line1_start->Clone(), line2_end->Clone());
1011 EXPECT_EQ(LINE_1.substr(0, 2),
1012 test_range.GetText(AXTextConcatenationBehavior::kAsInnerText, 2));
1013
1014 // Test the case where an appended newline falls right at max_count.
1015 EXPECT_EQ(LINE_1.substr().append(NEWLINE),
1016 test_range.GetText(AXTextConcatenationBehavior::kAsInnerText, 7));
1017
1018 // Test passing -1 for max_count.
1019 EXPECT_EQ(LINE_1.substr().append(NEWLINE).append(LINE_2),
1020 test_range.GetText(AXTextConcatenationBehavior::kAsInnerText, -1));
1021}
static void test_range(skiatest::Reporter *reporter)
Definition: RandomTest.cpp:167

◆ TEST_F() [306/325]

ui::TEST_F ( AXRangeTest  ,
GetTextWithTextOffsets   
)

Definition at line 822 of file ax_range_unittest.cc.

822 {
823 std::u16string most_text = BUTTON.substr(2).append(TEXT_FIELD.substr(0, 11));
824 // Create a range starting from the button object and ending two characters
825 // before the end of the root.
827 GetTreeID(), button_.id, 2 /* text_offset */,
829 ASSERT_TRUE(start->IsTextPosition());
831 GetTreeID(), static_text2_.id, 4 /* text_offset */,
833 ASSERT_TRUE(end->IsTextPosition());
834 TestPositionRange forward_range(start->Clone(), end->Clone());
835 EXPECT_EQ(most_text, forward_range.GetText());
836 TestPositionRange backward_range(std::move(end), std::move(start));
837 EXPECT_EQ(most_text, backward_range.GetText());
838
839 // root_ to static_text2_'s start with offsets
840 std::u16string text_up_to_text2_tree_start =
841 BUTTON.substr(0).append(TEXT_FIELD.substr(0, 10));
842 start = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
843 0 /* child_index */);
845 GetTreeID(), static_text2_.id, 3 /* text_offset */,
847 ASSERT_TRUE(end->IsTextPosition());
848 TestPositionRange root_to_static2_tree_range(start->Clone(), end->Clone());
849 EXPECT_EQ(text_up_to_text2_tree_start, root_to_static2_tree_range.GetText());
850 TestPositionRange root_to_static2_tree_range_backward(std::move(end),
851 std::move(start));
852 EXPECT_EQ(text_up_to_text2_tree_start,
853 root_to_static2_tree_range_backward.GetText());
854}

◆ TEST_F() [307/325]

ui::TEST_F ( AXRangeTest  ,
GetTextWithWholeObjects   
)

Definition at line 699 of file ax_range_unittest.cc.

699 {
700 // Create a range starting from the button object and ending at the last
701 // character of the root, i.e. at the last character of the second line in the
702 // text field.
703 TestPositionInstance start = AXNodePosition::CreateTreePosition(
704 GetTreeID(), root_.id, 0 /* child_index */);
706 GetTreeID(), root_.id, ALL_TEXT.length() /* text_offset */,
708 ASSERT_TRUE(end->IsTextPosition());
709 TestPositionRange forward_range(start->Clone(), end->Clone());
710 EXPECT_EQ(ALL_TEXT, forward_range.GetText());
711 TestPositionRange backward_range(std::move(end), std::move(start));
712 EXPECT_EQ(ALL_TEXT, backward_range.GetText());
713
714 // Button
716 GetTreeID(), button_.id, 0 /* text_offset */,
718 ASSERT_TRUE(start->IsTextPosition());
720 GetTreeID(), button_.id, BUTTON.length() /* text_offset */,
722 ASSERT_TRUE(end->IsTextPosition());
723 TestPositionRange button_range(start->Clone(), end->Clone());
724 EXPECT_EQ(BUTTON, button_range.GetText());
725 TestPositionRange button_range_backward(std::move(end), std::move(start));
726 EXPECT_EQ(BUTTON, button_range_backward.GetText());
727
728 // text_field_
730 GetTreeID(), text_field_.id, 0 /* text_offset */,
733 GetTreeID(), text_field_.id, TEXT_FIELD.length() /* text_offset */,
735 ASSERT_TRUE(start->IsTextPosition());
736 ASSERT_TRUE(end->IsTextPosition());
737 TestPositionRange text_field_range(start->Clone(), end->Clone());
738 EXPECT_EQ(TEXT_FIELD, text_field_range.GetText());
739 TestPositionRange text_field_range_backward(std::move(end), std::move(start));
740 EXPECT_EQ(TEXT_FIELD, text_field_range_backward.GetText());
741
742 // static_text1_
744 GetTreeID(), static_text1_.id, 0 /* text_offset */,
746 ASSERT_TRUE(start->IsTextPosition());
748 GetTreeID(), static_text1_.id, LINE_1.length() /* text_offset */,
750 ASSERT_TRUE(end->IsTextPosition());
751 TestPositionRange static_text1_range(start->Clone(), end->Clone());
752 EXPECT_EQ(LINE_1, static_text1_range.GetText());
753 TestPositionRange static_text1_range_backward(std::move(end),
754 std::move(start));
755 EXPECT_EQ(LINE_1, static_text1_range_backward.GetText());
756
757 // static_text2_
759 GetTreeID(), static_text2_.id, 0 /* text_offset */,
761 ASSERT_TRUE(start->IsTextPosition());
763 GetTreeID(), static_text2_.id, LINE_2.length() /* text_offset */,
765 ASSERT_TRUE(end->IsTextPosition());
766 TestPositionRange static_text2_range(start->Clone(), end->Clone());
767 EXPECT_EQ(LINE_2, static_text2_range.GetText());
768 TestPositionRange static_text2_range_backward(std::move(end),
769 std::move(start));
770 EXPECT_EQ(LINE_2, static_text2_range_backward.GetText());
771
772 // static_text1_ to static_text2_
773 std::u16string text_between_text1_start_and_text2_end =
774 LINE_1.substr().append(NEWLINE).append(LINE_2);
776 GetTreeID(), static_text1_.id, 0 /* text_offset */,
778 ASSERT_TRUE(start->IsTextPosition());
780 GetTreeID(), static_text2_.id, LINE_2.length() /* text_offset */,
782 ASSERT_TRUE(end->IsTextPosition());
783 TestPositionRange static_text_range(start->Clone(), end->Clone());
784 EXPECT_EQ(text_between_text1_start_and_text2_end,
785 static_text_range.GetText());
786 TestPositionRange static_text_range_backward(std::move(end),
787 std::move(start));
788 EXPECT_EQ(text_between_text1_start_and_text2_end,
789 static_text_range_backward.GetText());
790
791 // root_ to static_text2_'s end
792 std::u16string text_up_to_text2_end =
793 BUTTON.substr(0).append(LINE_1).append(NEWLINE).append(LINE_2);
794 start = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
795 0 /* child_index */);
797 GetTreeID(), static_text2_.id, LINE_2.length() /* text_offset */,
799 ASSERT_TRUE(end->IsTextPosition());
800 TestPositionRange root_to_static2_text_range(start->Clone(), end->Clone());
801 EXPECT_EQ(text_up_to_text2_end, root_to_static2_text_range.GetText());
802 TestPositionRange root_to_static2_text_range_backward(std::move(end),
803 std::move(start));
804 EXPECT_EQ(text_up_to_text2_end,
805 root_to_static2_text_range_backward.GetText());
806
807 // root_ to static_text2_'s start
808 std::u16string text_up_to_text2_start =
809 BUTTON.substr(0).append(LINE_1).append(NEWLINE);
810 start = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
811 0 /* child_index */);
812 end = AXNodePosition::CreateTreePosition(GetTreeID(), static_text2_.id,
813 0 /* child_index */);
814 TestPositionRange root_to_static2_tree_range(start->Clone(), end->Clone());
815 EXPECT_EQ(text_up_to_text2_start, root_to_static2_tree_range.GetText());
816 TestPositionRange root_to_static2_tree_range_backward(std::move(end),
817 std::move(start));
818 EXPECT_EQ(text_up_to_text2_start,
819 root_to_static2_tree_range_backward.GetText());
820}

◆ TEST_F() [308/325]

ui::TEST_F ( AXRangeTest  ,
IsCollapsed   
)

Definition at line 397 of file ax_range_unittest.cc.

397 {
398 TestPositionRange null_range(AXNodePosition::CreateNullPosition(),
399 AXNodePosition::CreateNullPosition());
400 null_range = null_range.AsForwardRange();
401 EXPECT_FALSE(null_range.IsCollapsed());
402
403 TestPositionInstance tree_position1 = AXNodePosition::CreateTreePosition(
404 GetTreeID(), text_field_.id, 0 /* child_index */);
405 // Since there are no children in inline_box1_, the following is essentially
406 // an "after text" position which should not compare as equivalent to the
407 // above tree position which is a "before text" position inside the text
408 // field.
409 TestPositionInstance tree_position2 = AXNodePosition::CreateTreePosition(
410 GetTreeID(), inline_box1_.id, 0 /* child_index */);
411
413 GetTreeID(), static_text1_.id, 0 /* text_offset */,
416 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
419 GetTreeID(), inline_box2_.id, 1 /* text_offset */,
421
422 TestPositionRange tree_to_null_range(tree_position1->Clone(),
423 AXNodePosition::CreateNullPosition());
424 EXPECT_TRUE(tree_to_null_range.IsNull());
425 EXPECT_FALSE(tree_to_null_range.IsCollapsed());
426
427 TestPositionRange null_to_text_range(AXNodePosition::CreateNullPosition(),
428 text_position1->Clone());
429 EXPECT_TRUE(null_to_text_range.IsNull());
430 EXPECT_FALSE(null_to_text_range.IsCollapsed());
431
432 TestPositionRange tree_to_tree_range(tree_position2->Clone(),
433 tree_position1->Clone());
434 EXPECT_TRUE(tree_to_tree_range.IsCollapsed());
435
436 // A tree and a text position that essentially point to the same text offset
437 // are equivalent, even if they are anchored to a different node.
438 TestPositionRange tree_to_text_range(tree_position1->Clone(),
439 text_position1->Clone());
440 EXPECT_TRUE(tree_to_text_range.IsCollapsed());
441
442 // The following positions are not equivalent since tree_position2 is an
443 // "after text" position.
444 tree_to_text_range =
445 TestPositionRange(tree_position2->Clone(), text_position2->Clone());
446 EXPECT_FALSE(tree_to_text_range.IsCollapsed());
447
448 TestPositionRange text_to_text_range(text_position1->Clone(),
449 text_position1->Clone());
450 EXPECT_TRUE(text_to_text_range.IsCollapsed());
451
452 // Two text positions that essentially point to the same text offset are
453 // equivalent, even if they are anchored to a different node.
454 text_to_text_range =
455 TestPositionRange(text_position1->Clone(), text_position2->Clone());
456 EXPECT_TRUE(text_to_text_range.IsCollapsed());
457
458 text_to_text_range =
459 TestPositionRange(text_position1->Clone(), text_position3->Clone());
460 EXPECT_FALSE(text_to_text_range.IsCollapsed());
461}

◆ TEST_F() [309/325]

ui::TEST_F ( AXRangeTest  ,
LeafTextRangeIteration   
)

Definition at line 527 of file ax_range_unittest.cc.

527 {
529 GetTreeID(), button_.id, 0 /* text_offset */,
532 GetTreeID(), button_.id, 3 /* text_offset */,
535 GetTreeID(), button_.id, 6 /* text_offset */,
537
538 // Since a check box is not visible to the text representation, it spans an
539 // empty anchor whose start and end positions are the same.
541 GetTreeID(), check_box1_.id, 0 /* text_offset */,
544 GetTreeID(), check_box2_.id, 0 /* text_offset */,
546
548 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
551 GetTreeID(), inline_box1_.id, 3 /* text_offset */,
554 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
556
558 GetTreeID(), line_break1_.id, 0 /* text_offset */,
561 GetTreeID(), line_break1_.id, 1 /* text_offset */,
563
565 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
568 GetTreeID(), inline_box2_.id, 3 /* text_offset */,
571 GetTreeID(), inline_box2_.id, 6 /* text_offset */,
573
575 GetTreeID(), line_break2_.id, 0 /* text_offset */,
578 GetTreeID(), line_break2_.id, 1 /* text_offset */,
580
582 GetTreeID(), inline_box3_.id, 0 /* text_offset */,
585 GetTreeID(), inline_box3_.id, 5 /* text_offset */,
587
588 std::vector<TestPositionRange> expected_ranges;
589 auto TestRangeIterator =
590 [&expected_ranges](const TestPositionRange& test_range) {
591 std::vector<TestPositionRange> actual_ranges;
592 for (TestPositionRange leaf_text_range : test_range) {
593 EXPECT_TRUE(leaf_text_range.IsLeafTextRange());
594 actual_ranges.emplace_back(std::move(leaf_text_range));
595 }
596
597 EXPECT_EQ(expected_ranges.size(), actual_ranges.size());
598 size_t element_count =
599 std::min(expected_ranges.size(), actual_ranges.size());
600 for (size_t i = 0; i < element_count; ++i) {
601 EXPECT_EQ(expected_ranges[i], actual_ranges[i]);
602 EXPECT_EQ(expected_ranges[i].anchor()->GetAnchor(),
603 actual_ranges[i].anchor()->GetAnchor());
604 }
605 };
606
607 // Iterating over a null range; note that expected_ranges is empty.
608 TestRangeIterator(TestPositionRange(nullptr, nullptr));
609
610 TestPositionRange non_null_degenerate_range(check_box1->Clone(),
611 check_box1->Clone());
612 expected_ranges.clear();
613 expected_ranges.emplace_back(check_box1->Clone(), check_box1->Clone());
614 TestRangeIterator(non_null_degenerate_range);
615
616 TestPositionRange empty_text_forward_range(button_end->Clone(),
617 line1_start->Clone());
618 TestPositionRange empty_text_backward_range(line1_start->Clone(),
619 button_end->Clone());
620 expected_ranges.clear();
621 expected_ranges.emplace_back(button_end->Clone(), button_end->Clone());
622 expected_ranges.emplace_back(check_box1->Clone(), check_box1->Clone());
623 expected_ranges.emplace_back(check_box2->Clone(), check_box2->Clone());
624 expected_ranges.emplace_back(line1_start->Clone(), line1_start->Clone());
625 TestRangeIterator(empty_text_forward_range);
626 TestRangeIterator(empty_text_backward_range);
627
628 TestPositionRange entire_anchor_forward_range(button_start->Clone(),
629 button_end->Clone());
630 TestPositionRange entire_anchor_backward_range(button_end->Clone(),
631 button_start->Clone());
632 expected_ranges.clear();
633 expected_ranges.emplace_back(button_start->Clone(), button_end->Clone());
634 TestRangeIterator(entire_anchor_forward_range);
635 TestRangeIterator(entire_anchor_backward_range);
636
637 TestPositionRange across_anchors_forward_range(button_middle->Clone(),
638 line1_middle->Clone());
639 TestPositionRange across_anchors_backward_range(line1_middle->Clone(),
640 button_middle->Clone());
641 expected_ranges.clear();
642 expected_ranges.emplace_back(button_middle->Clone(), button_end->Clone());
643 expected_ranges.emplace_back(check_box1->Clone(), check_box1->Clone());
644 expected_ranges.emplace_back(check_box2->Clone(), check_box2->Clone());
645 expected_ranges.emplace_back(line1_start->Clone(), line1_middle->Clone());
646 TestRangeIterator(across_anchors_forward_range);
647 TestRangeIterator(across_anchors_backward_range);
648
649 TestPositionRange starting_at_end_position_forward_range(
650 line1_end->Clone(), line2_middle->Clone());
651 TestPositionRange starting_at_end_position_backward_range(
652 line2_middle->Clone(), line1_end->Clone());
653 expected_ranges.clear();
654 expected_ranges.emplace_back(line1_end->Clone(), line1_end->Clone());
655 expected_ranges.emplace_back(line_break1_start->Clone(),
656 line_break1_end->Clone());
657 expected_ranges.emplace_back(line2_start->Clone(), line2_middle->Clone());
658 TestRangeIterator(starting_at_end_position_forward_range);
659 TestRangeIterator(starting_at_end_position_backward_range);
660
661 TestPositionRange ending_at_start_position_forward_range(
662 line1_middle->Clone(), line2_start->Clone());
663 TestPositionRange ending_at_start_position_backward_range(
664 line2_start->Clone(), line1_middle->Clone());
665 expected_ranges.clear();
666 expected_ranges.emplace_back(line1_middle->Clone(), line1_end->Clone());
667 expected_ranges.emplace_back(line_break1_start->Clone(),
668 line_break1_end->Clone());
669 expected_ranges.emplace_back(line2_start->Clone(), line2_start->Clone());
670 TestRangeIterator(ending_at_start_position_forward_range);
671 TestRangeIterator(ending_at_start_position_backward_range);
672
673 TestPositionInstance range_start = AXNodePosition::CreateTreePosition(
674 GetTreeID(), root_.id, 0 /* child_index */);
676 GetTreeID(), root_.id, ALL_TEXT.length() /* text_offset */,
678
679 TestPositionRange entire_test_forward_range(range_start->Clone(),
680 range_end->Clone());
681 TestPositionRange entire_test_backward_range(range_end->Clone(),
682 range_start->Clone());
683 expected_ranges.clear();
684 expected_ranges.emplace_back(button_start->Clone(), button_end->Clone());
685 expected_ranges.emplace_back(check_box1->Clone(), check_box1->Clone());
686 expected_ranges.emplace_back(check_box2->Clone(), check_box2->Clone());
687 expected_ranges.emplace_back(line1_start->Clone(), line1_end->Clone());
688 expected_ranges.emplace_back(line_break1_start->Clone(),
689 line_break1_end->Clone());
690 expected_ranges.emplace_back(line2_start->Clone(), line2_end->Clone());
691 expected_ranges.emplace_back(line_break2_start->Clone(),
692 line_break2_end->Clone());
693 expected_ranges.emplace_back(after_line_start->Clone(),
694 after_line_end->Clone());
695 TestRangeIterator(entire_test_forward_range);
696 TestRangeIterator(entire_test_backward_range);
697}
static float min(float r, float g, float b)
Definition: hsl.cpp:48

◆ TEST_F() [310/325]

ui::TEST_F ( AXTableInfoTest  ,
AriaIndicesInferred   
)

Definition at line 812 of file ax_table_info_unittest.cc.

812 {
813 // Note that ARIA indices are 1-based, whereas the rest of
814 // the table indices are zero-based.
815 AXTreeUpdate initial_state;
816 initial_state.root_id = 1;
817 initial_state.nodes.resize(13);
818 MakeTable(&initial_state.nodes[0], 1, 3, 3);
819 initial_state.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kAriaRowCount,
820 5);
821 initial_state.nodes[0].AddIntAttribute(
823 initial_state.nodes[0].child_ids = {2, 3, 4};
824 MakeRow(&initial_state.nodes[1], 2, 0);
825 initial_state.nodes[1].child_ids = {5, 6, 7};
826 MakeRow(&initial_state.nodes[2], 3, 1);
827 initial_state.nodes[2].AddIntAttribute(
829 initial_state.nodes[2].child_ids = {8, 9, 10};
830 MakeRow(&initial_state.nodes[3], 4, 2);
831 initial_state.nodes[3].AddIntAttribute(
833 initial_state.nodes[3].child_ids = {11, 12, 13};
834 MakeCell(&initial_state.nodes[4], 5, 0, 0);
835 initial_state.nodes[4].AddIntAttribute(
837 initial_state.nodes[4].AddIntAttribute(
839 MakeCell(&initial_state.nodes[5], 6, 0, 1);
840 MakeCell(&initial_state.nodes[6], 7, 0, 2);
841 MakeCell(&initial_state.nodes[7], 8, 1, 0);
842 MakeCell(&initial_state.nodes[8], 9, 1, 1);
843 MakeCell(&initial_state.nodes[9], 10, 1, 2);
844 MakeCell(&initial_state.nodes[10], 11, 2, 0);
845 initial_state.nodes[10].AddIntAttribute(
847 MakeCell(&initial_state.nodes[11], 12, 2, 1);
848 initial_state.nodes[11].AddIntAttribute(
850 MakeCell(&initial_state.nodes[12], 13, 2, 2);
851 initial_state.nodes[12].AddIntAttribute(
853 AXTree tree(initial_state);
854 AXNode* table = tree.root();
855
856 EXPECT_EQ(5, table->GetTableAriaColCount());
857 EXPECT_EQ(5, table->GetTableAriaRowCount());
858
859 EXPECT_EQ(3u, table->GetTableRowNodeIds().size());
860 EXPECT_EQ(2, table->GetTableRowNodeIds()[0]);
861 EXPECT_EQ(3, table->GetTableRowNodeIds()[1]);
862 EXPECT_EQ(4, table->GetTableRowNodeIds()[2]);
863
864 // The first row has the first cell ARIA row and column index
865 // specified as (2, 2). The rest of the row is inferred.
866
867 AXNode* cell_0_0 = tree.GetFromId(5);
868 EXPECT_EQ(2, cell_0_0->GetTableCellAriaRowIndex());
869 EXPECT_EQ(2, cell_0_0->GetTableCellAriaColIndex());
870
871 AXNode* cell_0_1 = tree.GetFromId(6);
872 EXPECT_EQ(2, cell_0_1->GetTableCellAriaRowIndex());
873 EXPECT_EQ(3, cell_0_1->GetTableCellAriaColIndex());
874
875 AXNode* cell_0_2 = tree.GetFromId(7);
876 EXPECT_EQ(2, cell_0_2->GetTableCellAriaRowIndex());
877 EXPECT_EQ(4, cell_0_2->GetTableCellAriaColIndex());
878
879 // The next row has the ARIA row index set to 4 on the row
880 // element. The rest is inferred.
881
882 AXNode* cell_1_0 = tree.GetFromId(8);
883 EXPECT_EQ(4, cell_1_0->GetTableCellAriaRowIndex());
884 EXPECT_EQ(1, cell_1_0->GetTableCellAriaColIndex());
885
886 AXNode* cell_1_1 = tree.GetFromId(9);
887 EXPECT_EQ(4, cell_1_1->GetTableCellAriaRowIndex());
888 EXPECT_EQ(2, cell_1_1->GetTableCellAriaColIndex());
889
890 AXNode* cell_1_2 = tree.GetFromId(10);
891 EXPECT_EQ(4, cell_1_2->GetTableCellAriaRowIndex());
892 EXPECT_EQ(3, cell_1_2->GetTableCellAriaColIndex());
893
894 // The last row has the ARIA row index set to 4 again, which is
895 // illegal so we should get 5. The cells have column indices of
896 // 3, 2, 1 which is illegal so we ignore the latter two and should
897 // end up with column indices of 3, 4, 5.
898
899 AXNode* cell_2_0 = tree.GetFromId(11);
900 EXPECT_EQ(5, cell_2_0->GetTableCellAriaRowIndex());
901 EXPECT_EQ(3, cell_2_0->GetTableCellAriaColIndex());
902
903 AXNode* cell_2_1 = tree.GetFromId(12);
904 EXPECT_EQ(5, cell_2_1->GetTableCellAriaRowIndex());
905 EXPECT_EQ(4, cell_2_1->GetTableCellAriaColIndex());
906
907 AXNode* cell_2_2 = tree.GetFromId(13);
908 EXPECT_EQ(5, cell_2_2->GetTableCellAriaRowIndex());
909 EXPECT_EQ(5, cell_2_2->GetTableCellAriaColIndex());
910}
SI F table(const skcms_Curve *curve, F v)

◆ TEST_F() [311/325]

ui::TEST_F ( AXTableInfoTest  ,
AuthorRowAndColumnCountsAreRespected   
)

Definition at line 275 of file ax_table_info_unittest.cc.

275 {
276 // Simple 1 x 1 table, but the table's authored row and column
277 // counts imply a larger table (with missing cells).
278 AXTreeUpdate initial_state;
279 initial_state.root_id = 1;
280 initial_state.nodes.resize(3);
281 MakeTable(&initial_state.nodes[0], 1, 8, 9);
282 initial_state.nodes[0].child_ids = {2};
283 MakeRow(&initial_state.nodes[1], 2, 0);
284 initial_state.nodes[1].child_ids = {3};
285 MakeCell(&initial_state.nodes[2], 3, 0, 1);
286 AXTree tree(initial_state);
287
288 AXTableInfo* table_info = GetTableInfo(&tree, tree.root());
289 EXPECT_EQ(8u, table_info->row_count);
290 EXPECT_EQ(9u, table_info->col_count);
291
292 EXPECT_EQ(1u, table_info->row_nodes.size());
293 EXPECT_EQ(2, table_info->row_nodes[0]->data().id);
294}

◆ TEST_F() [312/325]

ui::TEST_F ( AXTableInfoTest  ,
BadColIndicesIgnored   
)

Definition at line 771 of file ax_table_info_unittest.cc.

771 {
772 // The table claims it has two rows and two columns, but
773 // the cell indices for the columns either repeat or
774 // go backwards.
775 AXTreeUpdate initial_state;
776 initial_state.root_id = 1;
777 initial_state.nodes.resize(7);
778 MakeTable(&initial_state.nodes[0], 1, 2, 2);
779 initial_state.nodes[0].child_ids = {2, 3};
780 MakeRow(&initial_state.nodes[1], 2, 0);
781 initial_state.nodes[1].child_ids = {4, 5};
782 MakeRow(&initial_state.nodes[2], 3, 0);
783 initial_state.nodes[2].child_ids = {6, 7};
784 MakeCell(&initial_state.nodes[3], 4, 0, 1);
785 MakeCell(&initial_state.nodes[4], 5, 0, 1);
786 MakeCell(&initial_state.nodes[5], 6, 1, 2);
787 MakeCell(&initial_state.nodes[6], 7, 1, 1);
788 AXTree tree(initial_state);
789 AXNode* table = tree.root();
790
791 EXPECT_EQ(4, table->GetTableColCount());
792 EXPECT_EQ(2, table->GetTableRowCount());
793
794 EXPECT_EQ(2u, table->GetTableRowNodeIds().size());
795 EXPECT_EQ(2, table->GetTableRowNodeIds()[0]);
796 EXPECT_EQ(3, table->GetTableRowNodeIds()[1]);
797
798 AXNode* cell_id_4 = tree.GetFromId(4);
799 EXPECT_EQ(0, cell_id_4->GetTableCellRowIndex());
800 EXPECT_EQ(1, cell_id_4->GetTableCellColIndex());
801 AXNode* cell_id_5 = tree.GetFromId(5);
802 EXPECT_EQ(0, cell_id_5->GetTableCellRowIndex());
803 EXPECT_EQ(2, cell_id_5->GetTableCellColIndex());
804 AXNode* cell_id_6 = tree.GetFromId(6);
805 EXPECT_EQ(1, cell_id_6->GetTableCellRowIndex());
806 EXPECT_EQ(2, cell_id_6->GetTableCellColIndex());
807 AXNode* cell_id_7 = tree.GetFromId(7);
808 EXPECT_EQ(1, cell_id_7->GetTableCellRowIndex());
809 EXPECT_EQ(3, cell_id_7->GetTableCellColIndex());
810}

◆ TEST_F() [313/325]

ui::TEST_F ( AXTableInfoTest  ,
BadRowIndicesIgnored   
)

Definition at line 726 of file ax_table_info_unittest.cc.

726 {
727 // The table claims it has two rows and two columns, but
728 // the cell indices for both the first and second rows
729 // are for row 2 (zero-based).
730 //
731 // The cell indexes for the first row should be
732 // respected, and for the second row it will get the
733 // next row index.
734 AXTreeUpdate initial_state;
735 initial_state.root_id = 1;
736 initial_state.nodes.resize(7);
737 MakeTable(&initial_state.nodes[0], 1, 2, 2);
738 initial_state.nodes[0].child_ids = {2, 3};
739 MakeRow(&initial_state.nodes[1], 2, 0);
740 initial_state.nodes[1].child_ids = {4, 5};
741 MakeRow(&initial_state.nodes[2], 3, 0);
742 initial_state.nodes[2].child_ids = {6, 7};
743 MakeCell(&initial_state.nodes[3], 4, 2, 0);
744 MakeCell(&initial_state.nodes[4], 5, 2, 1);
745 MakeCell(&initial_state.nodes[5], 6, 2, 0);
746 MakeCell(&initial_state.nodes[6], 7, 2, 1);
747 AXTree tree(initial_state);
748 AXNode* table = tree.root();
749
750 EXPECT_EQ(2, table->GetTableColCount());
751 EXPECT_EQ(4, table->GetTableRowCount());
752
753 EXPECT_EQ(2u, table->GetTableRowNodeIds().size());
754 EXPECT_EQ(2, table->GetTableRowNodeIds()[0]);
755 EXPECT_EQ(3, table->GetTableRowNodeIds()[1]);
756
757 AXNode* cell_id_4 = tree.GetFromId(4);
758 EXPECT_EQ(2, cell_id_4->GetTableCellRowIndex());
759 EXPECT_EQ(0, cell_id_4->GetTableCellColIndex());
760 AXNode* cell_id_5 = tree.GetFromId(5);
761 EXPECT_EQ(2, cell_id_5->GetTableCellRowIndex());
762 EXPECT_EQ(1, cell_id_5->GetTableCellColIndex());
763 AXNode* cell_id_6 = tree.GetFromId(6);
764 EXPECT_EQ(3, cell_id_6->GetTableCellRowIndex());
765 EXPECT_EQ(0, cell_id_6->GetTableCellColIndex());
766 AXNode* cell_id_7 = tree.GetFromId(7);
767 EXPECT_EQ(3, cell_id_7->GetTableCellRowIndex());
768 EXPECT_EQ(1, cell_id_7->GetTableCellColIndex());
769}

◆ TEST_F() [314/325]

ui::TEST_F ( AXTableInfoTest  ,
CellIdsHandlesSpansAndMissingCells   
)

Definition at line 329 of file ax_table_info_unittest.cc.

329 {
330 // 3 column x 2 row table with spans and missing cells:
331 //
332 // +---+---+---+
333 // | | 5 |
334 // + 4 +---+---+
335 // | | 6 |
336 // +---+---+
337 AXTreeUpdate initial_state;
338 initial_state.root_id = 1;
339 initial_state.nodes.resize(6);
340 MakeTable(&initial_state.nodes[0], 1, 0, 0);
341 initial_state.nodes[0].child_ids = {2, 3};
342 MakeRow(&initial_state.nodes[1], 2, 0);
343 initial_state.nodes[1].child_ids = {4, 5};
344 MakeRow(&initial_state.nodes[2], 3, 1);
345 initial_state.nodes[2].child_ids = {6};
346 MakeCell(&initial_state.nodes[3], 4, 0, 0, 2, 1); // Row span of 2
347 MakeCell(&initial_state.nodes[4], 5, 0, 1, 1, 5); // Column span of 2
348 MakeCell(&initial_state.nodes[5], 6, 1, 1);
349 AXTree tree(initial_state);
350
351 AXTableInfo* table_info = GetTableInfo(&tree, tree.root());
352 EXPECT_EQ(4, table_info->cell_ids[0][0]);
353 EXPECT_EQ(5, table_info->cell_ids[0][1]);
354 EXPECT_EQ(5, table_info->cell_ids[0][1]);
355 EXPECT_EQ(4, table_info->cell_ids[1][0]);
356 EXPECT_EQ(6, table_info->cell_ids[1][1]);
357 EXPECT_EQ(0, table_info->cell_ids[1][2]);
358
359 EXPECT_EQ(3U, table_info->unique_cell_ids.size());
360 EXPECT_EQ(4, table_info->unique_cell_ids[0]);
361 EXPECT_EQ(5, table_info->unique_cell_ids[1]);
362 EXPECT_EQ(6, table_info->unique_cell_ids[2]);
363
364 EXPECT_EQ(0u, table_info->cell_id_to_index[4]);
365 EXPECT_EQ(1u, table_info->cell_id_to_index[5]);
366 EXPECT_EQ(2u, table_info->cell_id_to_index[6]);
367
368 EXPECT_EQ(2u, table_info->row_nodes.size());
369 EXPECT_EQ(2, table_info->row_nodes[0]->data().id);
370 EXPECT_EQ(3, table_info->row_nodes[1]->data().id);
371}

◆ TEST_F() [315/325]

ui::TEST_F ( AXTableInfoTest  ,
ComputedTableSizeIncludesSpans   
)

Definition at line 248 of file ax_table_info_unittest.cc.

248 {
249 // Simple 2 x 2 table with 2 column headers in first row, 2 cells in second
250 // row, but two cells have spans, affecting the computed row and column count.
251 AXTreeUpdate initial_state;
252 initial_state.root_id = 1;
253 initial_state.nodes.resize(7);
254 MakeTable(&initial_state.nodes[0], 1, 0, 0);
255 initial_state.nodes[0].child_ids = {2, 3};
256 MakeRow(&initial_state.nodes[1], 2, 0);
257 initial_state.nodes[1].child_ids = {4, 5};
258 MakeRow(&initial_state.nodes[2], 3, 1);
259 initial_state.nodes[2].child_ids = {6, 7};
260 MakeCell(&initial_state.nodes[3], 4, 0, 0);
261 MakeCell(&initial_state.nodes[4], 5, 0, 1, 1, 5); // Column span of 5
262 MakeCell(&initial_state.nodes[5], 6, 1, 0);
263 MakeCell(&initial_state.nodes[6], 7, 1, 1, 3, 1); // Row span of 3
264 AXTree tree(initial_state);
265
266 AXTableInfo* table_info = GetTableInfo(&tree, tree.root());
267 EXPECT_EQ(4u, table_info->row_count);
268 EXPECT_EQ(6u, table_info->col_count);
269
270 EXPECT_EQ(2u, table_info->row_nodes.size());
271 EXPECT_EQ(2, table_info->row_nodes[0]->data().id);
272 EXPECT_EQ(3, table_info->row_nodes[1]->data().id);
273}

◆ TEST_F() [316/325]

ui::TEST_F ( AXTableInfoTest  ,
ExtraMacNodes   
)

Definition at line 495 of file ax_table_info_unittest.cc.

495 {
496 // Simple 2 x 2 table with 2 column headers in first row, 2 cells in second
497 // row.
498 AXTreeUpdate initial_state;
499 initial_state.root_id = 1;
500 initial_state.nodes.resize(7);
501 MakeTable(&initial_state.nodes[0], 1, 0, 0);
502 initial_state.nodes[0].child_ids = {2, 3};
503 MakeRow(&initial_state.nodes[1], 2, 0);
504 initial_state.nodes[1].child_ids = {4, 5};
505 MakeRow(&initial_state.nodes[2], 3, 1);
506 initial_state.nodes[2].child_ids = {6, 7};
507 MakeColumnHeader(&initial_state.nodes[3], 4, 0, 0);
508 MakeColumnHeader(&initial_state.nodes[4], 5, 0, 1);
509 MakeCell(&initial_state.nodes[5], 6, 1, 0);
510 MakeCell(&initial_state.nodes[6], 7, 1, 1);
511 AXTree tree(initial_state);
512
513 tree.SetEnableExtraMacNodes(true);
514 AXTableInfo* table_info = GetTableInfo(&tree, tree.root()->children()[0]);
515 EXPECT_FALSE(table_info);
516
517 table_info = GetTableInfo(&tree, tree.root());
518 EXPECT_TRUE(table_info);
519
520 // We expect 3 extra Mac nodes: two column nodes, and one header node.
521 EXPECT_EQ(3U, table_info->extra_mac_nodes.size());
522
523 // The first column.
524 AXNodeData extra_node_0 = table_info->extra_mac_nodes[0]->data();
525 EXPECT_EQ(-1, table_info->extra_mac_nodes[0]->id());
526 EXPECT_EQ(1, table_info->extra_mac_nodes[0]->parent()->id());
527 EXPECT_EQ(ax::mojom::Role::kColumn, extra_node_0.role);
528 EXPECT_EQ(2U, table_info->extra_mac_nodes[0]->GetIndexInParent());
529 EXPECT_EQ(2U, table_info->extra_mac_nodes[0]->GetUnignoredIndexInParent());
530 EXPECT_EQ(0, extra_node_0.GetIntAttribute(
532 std::vector<int32_t> indirect_child_ids;
533 EXPECT_EQ(true, extra_node_0.GetIntListAttribute(
535 &indirect_child_ids));
536 EXPECT_EQ(2U, indirect_child_ids.size());
537 EXPECT_EQ(4, indirect_child_ids[0]);
538 EXPECT_EQ(6, indirect_child_ids[1]);
539
540 // The second column.
541 AXNodeData extra_node_1 = table_info->extra_mac_nodes[1]->data();
542 EXPECT_EQ(-2, table_info->extra_mac_nodes[1]->id());
543 EXPECT_EQ(1, table_info->extra_mac_nodes[1]->parent()->id());
544 EXPECT_EQ(ax::mojom::Role::kColumn, extra_node_1.role);
545 EXPECT_EQ(3U, table_info->extra_mac_nodes[1]->GetIndexInParent());
546 EXPECT_EQ(3U, table_info->extra_mac_nodes[1]->GetUnignoredIndexInParent());
547 EXPECT_EQ(1, extra_node_1.GetIntAttribute(
549 indirect_child_ids.clear();
550 EXPECT_EQ(true, extra_node_1.GetIntListAttribute(
552 &indirect_child_ids));
553 EXPECT_EQ(2U, indirect_child_ids.size());
554 EXPECT_EQ(5, indirect_child_ids[0]);
555 EXPECT_EQ(7, indirect_child_ids[1]);
556
557 // The table header container.
558 AXNodeData extra_node_2 = table_info->extra_mac_nodes[2]->data();
559 EXPECT_EQ(-3, table_info->extra_mac_nodes[2]->id());
560 EXPECT_EQ(1, table_info->extra_mac_nodes[2]->parent()->id());
561 EXPECT_EQ(ax::mojom::Role::kTableHeaderContainer, extra_node_2.role);
562 EXPECT_EQ(4U, table_info->extra_mac_nodes[2]->GetIndexInParent());
563 EXPECT_EQ(4U, table_info->extra_mac_nodes[2]->GetUnignoredIndexInParent());
564 indirect_child_ids.clear();
565 EXPECT_EQ(true, extra_node_2.GetIntListAttribute(
567 &indirect_child_ids));
568 EXPECT_EQ(2U, indirect_child_ids.size());
569 EXPECT_EQ(4, indirect_child_ids[0]);
570 EXPECT_EQ(5, indirect_child_ids[1]);
571}

◆ TEST_F() [317/325]

ui::TEST_F ( AXTableInfoTest  ,
ExtraMacNodesChanges   
)

Definition at line 940 of file ax_table_info_unittest.cc.

940 {
941 // Simple 2 x 2 table with 2 column headers in first row, 2 cells in second
942 // row.
943 AXTreeUpdate initial_state;
944 initial_state.root_id = 1;
945 initial_state.nodes.resize(7);
946 MakeTable(&initial_state.nodes[0], 1, 0, 0);
947 initial_state.nodes[0].child_ids = {2, 3};
948 MakeRow(&initial_state.nodes[1], 2, 0);
949 initial_state.nodes[1].child_ids = {4, 5};
950 MakeRow(&initial_state.nodes[2], 3, 1);
951 initial_state.nodes[2].child_ids = {6, 7};
952 MakeColumnHeader(&initial_state.nodes[3], 4, 0, 0);
953 MakeColumnHeader(&initial_state.nodes[4], 5, 0, 1);
954 MakeCell(&initial_state.nodes[5], 6, 1, 0);
955 MakeCell(&initial_state.nodes[6], 7, 1, 1);
956 AXTree tree(initial_state);
957
958 tree.SetEnableExtraMacNodes(true);
959 AXTableInfo* table_info = GetTableInfo(&tree, tree.root());
960 ASSERT_NE(nullptr, table_info);
961 // We expect 3 extra Mac nodes: two column nodes, and one header node.
962 ASSERT_EQ(3U, table_info->extra_mac_nodes.size());
963
964 // Hide the first row. The number of extra Mac nodes should remain the same,
965 // but their data should change.
966 AXTreeUpdate update1;
967 update1.nodes.resize(1);
968 MakeRow(&update1.nodes[0], 2, 0);
969 update1.nodes[0].AddState(ax::mojom::State::kIgnored);
970 update1.nodes[0].child_ids = {4, 5};
971 ASSERT_TRUE(tree.Unserialize(update1));
972 table_info = GetTableInfo(&tree, tree.root());
973 ASSERT_EQ(3U, table_info->extra_mac_nodes.size());
974
975 {
976 // The first column.
977 AXNodeData extra_node_0 = table_info->extra_mac_nodes[0]->data();
978 EXPECT_EQ(-4, table_info->extra_mac_nodes[0]->id());
979 EXPECT_EQ(1, table_info->extra_mac_nodes[0]->parent()->id());
980 EXPECT_EQ(ax::mojom::Role::kColumn, extra_node_0.role);
981 EXPECT_EQ(2U, table_info->extra_mac_nodes[0]->GetIndexInParent());
982 EXPECT_EQ(3U, table_info->extra_mac_nodes[0]->GetUnignoredIndexInParent());
983 EXPECT_EQ(0, extra_node_0.GetIntAttribute(
985 std::vector<int32_t> indirect_child_ids;
986 EXPECT_EQ(true, extra_node_0.GetIntListAttribute(
988 &indirect_child_ids));
989 EXPECT_EQ(1U, indirect_child_ids.size());
990 EXPECT_EQ(6, indirect_child_ids[0]);
991
992 // The second column.
993 AXNodeData extra_node_1 = table_info->extra_mac_nodes[1]->data();
994 EXPECT_EQ(-5, table_info->extra_mac_nodes[1]->id());
995 EXPECT_EQ(1, table_info->extra_mac_nodes[1]->parent()->id());
996 EXPECT_EQ(ax::mojom::Role::kColumn, extra_node_1.role);
997 EXPECT_EQ(3U, table_info->extra_mac_nodes[1]->GetIndexInParent());
998 EXPECT_EQ(4U, table_info->extra_mac_nodes[1]->GetUnignoredIndexInParent());
999 EXPECT_EQ(1, extra_node_1.GetIntAttribute(
1001 indirect_child_ids.clear();
1002 EXPECT_EQ(true, extra_node_1.GetIntListAttribute(
1004 &indirect_child_ids));
1005 EXPECT_EQ(1U, indirect_child_ids.size());
1006 EXPECT_EQ(7, indirect_child_ids[0]);
1007
1008 // The table header container.
1009 AXNodeData extra_node_2 = table_info->extra_mac_nodes[2]->data();
1010 EXPECT_EQ(-6, table_info->extra_mac_nodes[2]->id());
1011 EXPECT_EQ(1, table_info->extra_mac_nodes[2]->parent()->id());
1012 EXPECT_EQ(ax::mojom::Role::kTableHeaderContainer, extra_node_2.role);
1013 EXPECT_EQ(4U, table_info->extra_mac_nodes[2]->GetIndexInParent());
1014 EXPECT_EQ(5U, table_info->extra_mac_nodes[2]->GetUnignoredIndexInParent());
1015 indirect_child_ids.clear();
1016 EXPECT_EQ(true, extra_node_2.GetIntListAttribute(
1018 &indirect_child_ids));
1019 EXPECT_EQ(0U, indirect_child_ids.size());
1020 }
1021
1022 // Delete the first row. Again, the number of extra Mac nodes should remain
1023 // the same, but their data should change.
1024 AXTreeUpdate update2;
1025 update2.node_id_to_clear = 2;
1026 update2.nodes.resize(1);
1027 MakeTable(&update2.nodes[0], 1, 0, 0);
1028 update2.nodes[0].child_ids = {3};
1029 ASSERT_TRUE(tree.Unserialize(update2));
1030 table_info = GetTableInfo(&tree, tree.root());
1031 ASSERT_EQ(3U, table_info->extra_mac_nodes.size());
1032
1033 {
1034 // The first column.
1035 AXNodeData extra_node_0 = table_info->extra_mac_nodes[0]->data();
1036 EXPECT_EQ(-7, table_info->extra_mac_nodes[0]->id());
1037 EXPECT_EQ(1, table_info->extra_mac_nodes[0]->parent()->id());
1038 EXPECT_EQ(ax::mojom::Role::kColumn, extra_node_0.role);
1039 EXPECT_EQ(1U, table_info->extra_mac_nodes[0]->GetIndexInParent());
1040 EXPECT_EQ(1U, table_info->extra_mac_nodes[0]->GetUnignoredIndexInParent());
1041 EXPECT_EQ(0, extra_node_0.GetIntAttribute(
1043 std::vector<int32_t> indirect_child_ids;
1044 EXPECT_EQ(true, extra_node_0.GetIntListAttribute(
1046 &indirect_child_ids));
1047 EXPECT_EQ(1U, indirect_child_ids.size());
1048 EXPECT_EQ(6, indirect_child_ids[0]);
1049
1050 // The second column.
1051 AXNodeData extra_node_1 = table_info->extra_mac_nodes[1]->data();
1052 EXPECT_EQ(-8, table_info->extra_mac_nodes[1]->id());
1053 EXPECT_EQ(1, table_info->extra_mac_nodes[1]->parent()->id());
1054 EXPECT_EQ(ax::mojom::Role::kColumn, extra_node_1.role);
1055 EXPECT_EQ(2U, table_info->extra_mac_nodes[1]->GetIndexInParent());
1056 EXPECT_EQ(2U, table_info->extra_mac_nodes[1]->GetUnignoredIndexInParent());
1057 EXPECT_EQ(1, extra_node_1.GetIntAttribute(
1059 indirect_child_ids.clear();
1060 EXPECT_EQ(true, extra_node_1.GetIntListAttribute(
1062 &indirect_child_ids));
1063 EXPECT_EQ(1U, indirect_child_ids.size());
1064 EXPECT_EQ(7, indirect_child_ids[0]);
1065
1066 // The table header container.
1067 AXNodeData extra_node_2 = table_info->extra_mac_nodes[2]->data();
1068 EXPECT_EQ(-9, table_info->extra_mac_nodes[2]->id());
1069 EXPECT_EQ(1, table_info->extra_mac_nodes[2]->parent()->id());
1070 EXPECT_EQ(ax::mojom::Role::kTableHeaderContainer, extra_node_2.role);
1071 EXPECT_EQ(3U, table_info->extra_mac_nodes[2]->GetIndexInParent());
1072 EXPECT_EQ(3U, table_info->extra_mac_nodes[2]->GetUnignoredIndexInParent());
1073 indirect_child_ids.clear();
1074 EXPECT_EQ(true, extra_node_2.GetIntListAttribute(
1076 &indirect_child_ids));
1077 EXPECT_EQ(0U, indirect_child_ids.size());
1078 }
1079}

◆ TEST_F() [318/325]

ui::TEST_F ( AXTableInfoTest  ,
HeadersWithSpans   
)

Definition at line 431 of file ax_table_info_unittest.cc.

431 {
432 // Row and column headers spanning multiple cells.
433 // In the figure below, 5 and 6 are headers.
434 //
435 // +---+---+
436 // | 5 |
437 // +---+---+---+
438 // | | 7 |
439 // + 6 +---+---+
440 // | | | 8 |
441 // +---+ +---+
442 AXTreeUpdate initial_state;
443 initial_state.root_id = 1;
444 initial_state.nodes.resize(8);
445 MakeTable(&initial_state.nodes[0], 1, 0, 0);
446 initial_state.nodes[0].child_ids = {2, 3, 4};
447 MakeRow(&initial_state.nodes[1], 2, 0);
448 initial_state.nodes[1].child_ids = {5};
449 MakeRow(&initial_state.nodes[2], 3, 1);
450 initial_state.nodes[2].child_ids = {6, 7};
451 MakeRow(&initial_state.nodes[3], 4, 2);
452 initial_state.nodes[3].child_ids = {8};
453 MakeColumnHeader(&initial_state.nodes[4], 5, 0, 1, 1, 2);
454 MakeRowHeader(&initial_state.nodes[5], 6, 1, 0, 2, 1);
455 MakeCell(&initial_state.nodes[6], 7, 1, 1);
456 MakeCell(&initial_state.nodes[7], 8, 2, 2);
457 AXTree tree(initial_state);
458
459 AXTableInfo* table_info = GetTableInfo(&tree, tree.root()->children()[0]);
460 EXPECT_FALSE(table_info);
461
462 table_info = GetTableInfo(&tree, tree.root());
463 EXPECT_TRUE(table_info);
464
465 EXPECT_EQ(3U, table_info->row_headers.size());
466 EXPECT_EQ(0U, table_info->row_headers[0].size());
467 EXPECT_EQ(1U, table_info->row_headers[1].size());
468 EXPECT_EQ(6, table_info->row_headers[1][0]);
469 EXPECT_EQ(1U, table_info->row_headers[1].size());
470 EXPECT_EQ(6, table_info->row_headers[2][0]);
471
472 EXPECT_EQ(3U, table_info->col_headers.size());
473 EXPECT_EQ(0U, table_info->col_headers[0].size());
474 EXPECT_EQ(1U, table_info->col_headers[1].size());
475 EXPECT_EQ(5, table_info->col_headers[1][0]);
476 EXPECT_EQ(1U, table_info->col_headers[2].size());
477 EXPECT_EQ(5, table_info->col_headers[2][0]);
478
479 EXPECT_EQ(0, table_info->cell_ids[0][0]);
480 EXPECT_EQ(5, table_info->cell_ids[0][1]);
481 EXPECT_EQ(5, table_info->cell_ids[0][2]);
482 EXPECT_EQ(6, table_info->cell_ids[1][0]);
483 EXPECT_EQ(7, table_info->cell_ids[1][1]);
484 EXPECT_EQ(0, table_info->cell_ids[1][2]);
485 EXPECT_EQ(6, table_info->cell_ids[2][0]);
486 EXPECT_EQ(0, table_info->cell_ids[2][1]);
487 EXPECT_EQ(8, table_info->cell_ids[2][2]);
488
489 EXPECT_EQ(3u, table_info->row_nodes.size());
490 EXPECT_EQ(2, table_info->row_nodes[0]->data().id);
491 EXPECT_EQ(3, table_info->row_nodes[1]->data().id);
492 EXPECT_EQ(4, table_info->row_nodes[2]->data().id);
493}

◆ TEST_F() [319/325]

ui::TEST_F ( AXTableInfoTest  ,
RowColumnSpanChanges   
)

Definition at line 1081 of file ax_table_info_unittest.cc.

1081 {
1082 // Simple 2 col x 1 row table
1084 update.root_id = 1;
1085 update.nodes.resize(4);
1086 MakeTable(&update.nodes[0], 1, 0, 0);
1087 update.nodes[0].child_ids = {2};
1088 MakeRow(&update.nodes[1], 2, 0);
1089 update.nodes[1].child_ids = {3, 10};
1090 MakeCell(&update.nodes[2], 3, 0, 0);
1091 MakeCell(&update.nodes[3], 10, 0, 1);
1092 AXTree tree(update);
1093
1094 AXTableInfo* table_info = GetTableInfo(&tree, tree.root());
1095 ASSERT_TRUE(table_info);
1096
1097 EXPECT_EQ(1u, table_info->row_count);
1098 EXPECT_EQ(2u, table_info->col_count);
1099
1100 EXPECT_EQ("|3 |10|\n", table_info->ToString());
1101
1102 // Add a row to the table.
1103 update.nodes.resize(6);
1104 update.nodes[0].child_ids = {2, 4};
1105 MakeRow(&update.nodes[4], 4, 0);
1106 update.nodes[4].child_ids = {5};
1107 MakeCell(&update.nodes[5], 5, -1, -1);
1108
1109 tree.Unserialize(update);
1110
1111 table_info = GetTableInfo(&tree, tree.root());
1112 ASSERT_TRUE(table_info);
1113 EXPECT_EQ(2u, table_info->row_count);
1114 EXPECT_EQ(2u, table_info->col_count);
1115 EXPECT_EQ(
1116 "|3 |10|\n"
1117 "|5 |0 |\n",
1118 table_info->ToString());
1119
1120 // Add a row to the middle of the table, with a span. Intentionally omit other
1121 // rows from the update.
1122 update.nodes.resize(3);
1123 update.nodes[0].child_ids = {2, 6, 4};
1124 MakeRow(&update.nodes[1], 6, 0);
1125 update.nodes[1].child_ids = {7};
1126 MakeCell(&update.nodes[2], 7, -1, -1, 1, 2);
1127
1128 tree.Unserialize(update);
1129
1130 table_info = GetTableInfo(&tree, tree.root());
1131 ASSERT_TRUE(table_info);
1132 EXPECT_EQ(3u, table_info->row_count);
1133 EXPECT_EQ(2u, table_info->col_count);
1134 EXPECT_EQ(
1135 "|3 |10|\n"
1136 "|7 |7 |\n"
1137 "|5 |0 |\n",
1138 table_info->ToString());
1139
1140 // Add a row to the end of the table, with a span. Intentionally omit other
1141 // rows from the update.
1142 update.nodes.resize(3);
1143 update.nodes[0].child_ids = {2, 6, 4, 8};
1144 MakeRow(&update.nodes[1], 8, 0);
1145 update.nodes[1].child_ids = {9};
1146 MakeCell(&update.nodes[2], 9, -1, -1, 2, 3);
1147
1148 tree.Unserialize(update);
1149
1150 table_info = GetTableInfo(&tree, tree.root());
1151 ASSERT_TRUE(table_info);
1152 EXPECT_EQ(5u, table_info->row_count);
1153 EXPECT_EQ(3u, table_info->col_count);
1154 EXPECT_EQ(
1155 "|3 |10|0 |\n"
1156 "|7 |7 |0 |\n"
1157 "|5 |0 |0 |\n"
1158 "|9 |9 |9 |\n"
1159 "|9 |9 |9 |\n",
1160 table_info->ToString());
1161
1162 // Finally, delete a few rows.
1163 update.nodes.resize(1);
1164 update.nodes[0].child_ids = {6, 8};
1165
1166 tree.Unserialize(update);
1167
1168 table_info = GetTableInfo(&tree, tree.root());
1169 ASSERT_TRUE(table_info);
1170 EXPECT_EQ(3u, table_info->row_count);
1171 EXPECT_EQ(3u, table_info->col_count);
1172 EXPECT_EQ(
1173 "|7|7|0|\n"
1174 "|9|9|9|\n"
1175 "|9|9|9|\n",
1176 table_info->ToString());
1177}

◆ TEST_F() [320/325]

ui::TEST_F ( AXTableInfoTest  ,
SimpleTable   
)

Definition at line 97 of file ax_table_info_unittest.cc.

97 {
98 // Simple 2 x 2 table with 2 column headers in first row, 2 cells in second
99 // row. The first row is parented by a rowgroup.
100 AXTreeUpdate initial_state;
101 initial_state.root_id = 1;
102 initial_state.nodes.resize(8);
103 MakeTable(&initial_state.nodes[0], 1, 0, 0);
104 initial_state.nodes[0].child_ids = {888, 3};
105
106 MakeRowGroup(&initial_state.nodes[1], 888);
107 initial_state.nodes[1].child_ids = {2};
108
109 MakeRow(&initial_state.nodes[2], 2, 0);
110 initial_state.nodes[2].child_ids = {4, 5};
111
112 MakeRow(&initial_state.nodes[3], 3, 1);
113 initial_state.nodes[3].child_ids = {6, 7};
114 MakeColumnHeader(&initial_state.nodes[4], 4, 0, 0);
115 MakeColumnHeader(&initial_state.nodes[5], 5, 0, 1);
116 MakeCell(&initial_state.nodes[6], 6, 1, 0);
117 MakeCell(&initial_state.nodes[7], 7, 1, 1);
118 AXTree tree(initial_state);
119
120 //
121 // Low-level: test the AXTableInfo directly.
122 //
123
124 AXTableInfo* table_info = GetTableInfo(&tree, tree.root()->children()[0]);
125 EXPECT_FALSE(table_info);
126
127 table_info = GetTableInfo(&tree, tree.root());
128 EXPECT_TRUE(table_info);
129
130 EXPECT_EQ(2u, table_info->row_count);
131 EXPECT_EQ(2u, table_info->col_count);
132
133 EXPECT_EQ(2U, table_info->row_headers.size());
134 EXPECT_EQ(0U, table_info->row_headers[0].size());
135 EXPECT_EQ(0U, table_info->row_headers[1].size());
136
137 EXPECT_EQ(2U, table_info->col_headers.size());
138 EXPECT_EQ(1U, table_info->col_headers[0].size());
139 EXPECT_EQ(4, table_info->col_headers[0][0]);
140 EXPECT_EQ(1U, table_info->col_headers[1].size());
141 EXPECT_EQ(5, table_info->col_headers[1][0]);
142
143 EXPECT_EQ(4, table_info->cell_ids[0][0]);
144 EXPECT_EQ(5, table_info->cell_ids[0][1]);
145 EXPECT_EQ(6, table_info->cell_ids[1][0]);
146 EXPECT_EQ(7, table_info->cell_ids[1][1]);
147
148 EXPECT_EQ(4U, table_info->unique_cell_ids.size());
149 EXPECT_EQ(4, table_info->unique_cell_ids[0]);
150 EXPECT_EQ(5, table_info->unique_cell_ids[1]);
151 EXPECT_EQ(6, table_info->unique_cell_ids[2]);
152 EXPECT_EQ(7, table_info->unique_cell_ids[3]);
153
154 EXPECT_EQ(0u, table_info->cell_id_to_index[4]);
155 EXPECT_EQ(1u, table_info->cell_id_to_index[5]);
156 EXPECT_EQ(2u, table_info->cell_id_to_index[6]);
157 EXPECT_EQ(3u, table_info->cell_id_to_index[7]);
158
159 EXPECT_EQ(2u, table_info->row_nodes.size());
160 EXPECT_EQ(2, table_info->row_nodes[0]->data().id);
161 EXPECT_EQ(3, table_info->row_nodes[1]->data().id);
162
163 EXPECT_EQ(0U, table_info->extra_mac_nodes.size());
164
165 //
166 // High-level: Test the helper functions on AXNode.
167 //
168
169 AXNode* table = tree.root();
170 EXPECT_TRUE(table->IsTable());
171 EXPECT_FALSE(table->IsTableRow());
172 EXPECT_FALSE(table->IsTableCellOrHeader());
173 EXPECT_OPTIONAL_EQ(2, table->GetTableColCount());
174 EXPECT_OPTIONAL_EQ(2, table->GetTableRowCount());
175
176 ASSERT_TRUE(table->GetTableCellFromCoords(0, 0));
177 EXPECT_EQ(4, table->GetTableCellFromCoords(0, 0)->id());
178 EXPECT_EQ(5, table->GetTableCellFromCoords(0, 1)->id());
179 EXPECT_EQ(6, table->GetTableCellFromCoords(1, 0)->id());
180 EXPECT_EQ(7, table->GetTableCellFromCoords(1, 1)->id());
181 EXPECT_EQ(nullptr, table->GetTableCellFromCoords(2, 1));
182 EXPECT_EQ(nullptr, table->GetTableCellFromCoords(1, -1));
183
184 EXPECT_EQ(4, table->GetTableCellFromIndex(0)->id());
185 EXPECT_EQ(5, table->GetTableCellFromIndex(1)->id());
186 EXPECT_EQ(6, table->GetTableCellFromIndex(2)->id());
187 EXPECT_EQ(7, table->GetTableCellFromIndex(3)->id());
188 EXPECT_EQ(nullptr, table->GetTableCellFromIndex(-1));
189 EXPECT_EQ(nullptr, table->GetTableCellFromIndex(4));
190
191 AXNode* row_0 = tree.GetFromId(2);
192 EXPECT_FALSE(row_0->IsTable());
193 EXPECT_TRUE(row_0->IsTableRow());
194 EXPECT_FALSE(row_0->IsTableCellOrHeader());
195 EXPECT_OPTIONAL_EQ(0, row_0->GetTableRowRowIndex());
196
197 AXNode* row_1 = tree.GetFromId(3);
198 EXPECT_FALSE(row_1->IsTable());
199 EXPECT_TRUE(row_1->IsTableRow());
200 EXPECT_FALSE(row_1->IsTableCellOrHeader());
201 EXPECT_OPTIONAL_EQ(1, row_1->GetTableRowRowIndex());
202
203 AXNode* cell_0_0 = tree.GetFromId(4);
204 EXPECT_FALSE(cell_0_0->IsTable());
205 EXPECT_FALSE(cell_0_0->IsTableRow());
206 EXPECT_TRUE(cell_0_0->IsTableCellOrHeader());
207 EXPECT_OPTIONAL_EQ(0, cell_0_0->GetTableCellIndex());
208 EXPECT_OPTIONAL_EQ(0, cell_0_0->GetTableCellColIndex());
209 EXPECT_OPTIONAL_EQ(0, cell_0_0->GetTableCellRowIndex());
210 EXPECT_OPTIONAL_EQ(1, cell_0_0->GetTableCellColSpan());
211 EXPECT_OPTIONAL_EQ(1, cell_0_0->GetTableCellRowSpan());
212
213 AXNode* cell_1_1 = tree.GetFromId(7);
214 EXPECT_FALSE(cell_1_1->IsTable());
215 EXPECT_FALSE(cell_1_1->IsTableRow());
216 EXPECT_TRUE(cell_1_1->IsTableCellOrHeader());
217 EXPECT_OPTIONAL_EQ(3, cell_1_1->GetTableCellIndex());
218 EXPECT_OPTIONAL_EQ(1, cell_1_1->GetTableCellRowIndex());
219 EXPECT_OPTIONAL_EQ(1, cell_1_1->GetTableCellColSpan());
220 EXPECT_OPTIONAL_EQ(1, cell_1_1->GetTableCellRowSpan());
221
222 std::vector<AXNode*> col_headers;
223 cell_1_1->GetTableCellColHeaders(&col_headers);
224 EXPECT_EQ(1U, col_headers.size());
225 EXPECT_EQ(5, col_headers[0]->id());
226
227 std::vector<AXNode*> row_headers;
228 cell_1_1->GetTableCellRowHeaders(&row_headers);
229 EXPECT_EQ(0U, row_headers.size());
230
231 EXPECT_EQ(2u, table->GetTableRowNodeIds().size());
232 EXPECT_EQ(2, table->GetTableRowNodeIds()[0]);
233 EXPECT_EQ(3, table->GetTableRowNodeIds()[1]);
234 EXPECT_EQ(2u, row_0->GetTableRowNodeIds().size());
235 EXPECT_EQ(2, row_0->GetTableRowNodeIds()[0]);
236 EXPECT_EQ(3, row_0->GetTableRowNodeIds()[1]);
237 EXPECT_EQ(2u, row_1->GetTableRowNodeIds().size());
238 EXPECT_EQ(2, row_1->GetTableRowNodeIds()[0]);
239 EXPECT_EQ(3, row_1->GetTableRowNodeIds()[1]);
240 EXPECT_EQ(2u, cell_0_0->GetTableRowNodeIds().size());
241 EXPECT_EQ(2, cell_0_0->GetTableRowNodeIds()[0]);
242 EXPECT_EQ(3, cell_0_0->GetTableRowNodeIds()[1]);
243 EXPECT_EQ(2u, cell_1_1->GetTableRowNodeIds().size());
244 EXPECT_EQ(2, cell_1_1->GetTableRowNodeIds()[0]);
245 EXPECT_EQ(3, cell_1_1->GetTableRowNodeIds()[1]);
246}
#define EXPECT_OPTIONAL_EQ(expected, actual)

◆ TEST_F() [321/325]

ui::TEST_F ( AXTableInfoTest  ,
SkipsGenericAndIgnoredNodes   
)

Definition at line 373 of file ax_table_info_unittest.cc.

373 {
374 // Simple 2 x 2 table with 2 cells in the first row, 2 cells in the second
375 // row, but with extra divs and ignored nodes in the tree.
376 //
377 // 1 Table
378 // 2 Row
379 // 3 Ignored
380 // 4 Generic
381 // 5 Cell
382 // 6 Cell
383 // 7 Ignored
384 // 8 Row
385 // 9 Cell
386 // 10 Cell
387
388 AXTreeUpdate initial_state;
389 initial_state.root_id = 1;
390 initial_state.nodes.resize(10);
391 MakeTable(&initial_state.nodes[0], 1, 0, 0);
392 initial_state.nodes[0].child_ids = {2, 7};
393 MakeRow(&initial_state.nodes[1], 2, 0);
394 initial_state.nodes[1].child_ids = {3};
395 initial_state.nodes[2].id = 3;
396 initial_state.nodes[2].AddState(ax::mojom::State::kIgnored);
397 initial_state.nodes[2].child_ids = {4, 6};
398 initial_state.nodes[3].id = 4;
399 initial_state.nodes[3].role = ax::mojom::Role::kGenericContainer;
400 initial_state.nodes[3].child_ids = {5};
401 MakeCell(&initial_state.nodes[4], 5, 0, 0);
402 MakeCell(&initial_state.nodes[5], 6, 0, 1);
403 initial_state.nodes[6].id = 7;
404 initial_state.nodes[6].AddState(ax::mojom::State::kIgnored);
405 initial_state.nodes[6].child_ids = {8};
406 MakeRow(&initial_state.nodes[7], 8, 1);
407 initial_state.nodes[7].child_ids = {9, 10};
408 MakeCell(&initial_state.nodes[8], 9, 1, 0);
409 MakeCell(&initial_state.nodes[9], 10, 1, 1);
410 AXTree tree(initial_state);
411
412 AXTableInfo* table_info = GetTableInfo(&tree, tree.root()->children()[0]);
413 EXPECT_FALSE(table_info);
414
415 table_info = GetTableInfo(&tree, tree.root());
416 EXPECT_TRUE(table_info);
417
418 EXPECT_EQ(2u, table_info->row_count);
419 EXPECT_EQ(2u, table_info->col_count);
420
421 EXPECT_EQ(5, table_info->cell_ids[0][0]);
422 EXPECT_EQ(6, table_info->cell_ids[0][1]);
423 EXPECT_EQ(9, table_info->cell_ids[1][0]);
424 EXPECT_EQ(10, table_info->cell_ids[1][1]);
425
426 EXPECT_EQ(2u, table_info->row_nodes.size());
427 EXPECT_EQ(2, table_info->row_nodes[0]->data().id);
428 EXPECT_EQ(8, table_info->row_nodes[1]->data().id);
429}

◆ TEST_F() [322/325]

ui::TEST_F ( AXTableInfoTest  ,
TableChanges   
)

Definition at line 912 of file ax_table_info_unittest.cc.

912 {
913 // Simple 2 col x 1 row table
914 AXTreeUpdate initial_state;
915 initial_state.root_id = 1;
916 initial_state.nodes.resize(4);
917 MakeTable(&initial_state.nodes[0], 1, 0, 0);
918 initial_state.nodes[0].child_ids = {2};
919 MakeRow(&initial_state.nodes[1], 2, 0);
920 initial_state.nodes[1].child_ids = {3, 4};
921 MakeCell(&initial_state.nodes[2], 3, 0, 0);
922 MakeCell(&initial_state.nodes[3], 4, 0, 1);
923 AXTree tree(initial_state);
924
925 AXTableInfo* table_info = GetTableInfo(&tree, tree.root());
926 EXPECT_TRUE(table_info);
927
928 EXPECT_EQ(1u, table_info->row_count);
929 EXPECT_EQ(2u, table_info->col_count);
930
931 // Update the tree to remove the table role.
932 AXTreeUpdate update = initial_state;
933 update.nodes[0].role = ax::mojom::Role::kGroup;
934 ASSERT_TRUE(tree.Unserialize(update));
935
936 table_info = GetTableInfo(&tree, tree.root());
937 EXPECT_FALSE(table_info);
938}

◆ TEST_F() [323/325]

ui::TEST_F ( AXTableInfoTest  ,
TableInfoRecomputedOnlyWhenTableChanges   
)

Definition at line 296 of file ax_table_info_unittest.cc.

296 {
297 // Simple 1 x 1 table.
298 AXTreeUpdate initial_state;
299 initial_state.root_id = 1;
300 initial_state.nodes.resize(3);
301 MakeTable(&initial_state.nodes[0], 1, 0, 0);
302 initial_state.nodes[0].child_ids = {2};
303 MakeRow(&initial_state.nodes[1], 2, 0);
304 initial_state.nodes[1].child_ids = {3};
305 MakeCell(&initial_state.nodes[2], 3, 0, 0);
306 AXTree tree(initial_state);
307
308 AXTableInfo* table_info = GetTableInfo(&tree, tree.root());
309 EXPECT_EQ(1u, table_info->row_count);
310 EXPECT_EQ(1u, table_info->col_count);
311
312 // Table info is cached.
313 AXTableInfo* table_info_2 = GetTableInfo(&tree, tree.root());
314 EXPECT_EQ(table_info, table_info_2);
315
316 // Update the table so that the cell has a span.
317 AXTreeUpdate update = initial_state;
318 MakeCell(&update.nodes[2], 3, 0, 0, 1, 2);
319 EXPECT_TRUE(tree.Unserialize(update));
320
321 AXTableInfo* table_info_3 = GetTableInfo(&tree, tree.root());
322 EXPECT_EQ(1u, table_info_3->row_count);
323 EXPECT_EQ(2u, table_info_3->col_count);
324
325 EXPECT_EQ(1u, table_info->row_nodes.size());
326 EXPECT_EQ(2, table_info->row_nodes[0]->data().id);
327}

◆ TEST_F() [324/325]

ui::TEST_F ( AXTableInfoTest  ,
TableWithNoIndices   
)

Definition at line 573 of file ax_table_info_unittest.cc.

573 {
574 AXTreeUpdate initial_state;
575 initial_state.root_id = 1;
576 initial_state.nodes.resize(7);
577 initial_state.nodes[0].id = 1;
578 initial_state.nodes[0].role = ax::mojom::Role::kTable;
579 initial_state.nodes[0].child_ids = {2, 3};
580 initial_state.nodes[1].id = 2;
581 initial_state.nodes[1].role = ax::mojom::Role::kRow;
582 initial_state.nodes[1].child_ids = {4, 5};
583 initial_state.nodes[2].id = 3;
584 initial_state.nodes[2].role = ax::mojom::Role::kRow;
585 initial_state.nodes[2].child_ids = {6, 7};
586 initial_state.nodes[3].id = 4;
587 initial_state.nodes[3].role = ax::mojom::Role::kColumnHeader;
588 initial_state.nodes[4].id = 5;
589 initial_state.nodes[4].role = ax::mojom::Role::kColumnHeader;
590 initial_state.nodes[5].id = 6;
591 initial_state.nodes[5].role = ax::mojom::Role::kCell;
592 initial_state.nodes[6].id = 7;
593 initial_state.nodes[6].role = ax::mojom::Role::kCell;
594
595 AXTree tree(initial_state);
596 AXNode* table = tree.root();
597
598 EXPECT_TRUE(table->IsTable());
599 EXPECT_FALSE(table->IsTableRow());
600 EXPECT_FALSE(table->IsTableCellOrHeader());
601 EXPECT_EQ(2, table->GetTableColCount());
602 EXPECT_EQ(2, table->GetTableRowCount());
603
604 EXPECT_EQ(2u, table->GetTableRowNodeIds().size());
605 EXPECT_EQ(2, table->GetTableRowNodeIds()[0]);
606 EXPECT_EQ(3, table->GetTableRowNodeIds()[1]);
607
608 EXPECT_EQ(4, table->GetTableCellFromCoords(0, 0)->id());
609 EXPECT_EQ(5, table->GetTableCellFromCoords(0, 1)->id());
610 EXPECT_EQ(6, table->GetTableCellFromCoords(1, 0)->id());
611 EXPECT_EQ(7, table->GetTableCellFromCoords(1, 1)->id());
612 EXPECT_EQ(nullptr, table->GetTableCellFromCoords(2, 1));
613 EXPECT_EQ(nullptr, table->GetTableCellFromCoords(1, -1));
614
615 EXPECT_EQ(4, table->GetTableCellFromIndex(0)->id());
616 EXPECT_EQ(5, table->GetTableCellFromIndex(1)->id());
617 EXPECT_EQ(6, table->GetTableCellFromIndex(2)->id());
618 EXPECT_EQ(7, table->GetTableCellFromIndex(3)->id());
619 EXPECT_EQ(nullptr, table->GetTableCellFromIndex(-1));
620 EXPECT_EQ(nullptr, table->GetTableCellFromIndex(4));
621
622 AXNode* cell_0_0 = tree.GetFromId(4);
623 EXPECT_EQ(0, cell_0_0->GetTableCellRowIndex());
624 EXPECT_EQ(0, cell_0_0->GetTableCellColIndex());
625 AXNode* cell_0_1 = tree.GetFromId(5);
626 EXPECT_EQ(0, cell_0_1->GetTableCellRowIndex());
627 EXPECT_EQ(1, cell_0_1->GetTableCellColIndex());
628 AXNode* cell_1_0 = tree.GetFromId(6);
629 EXPECT_EQ(1, cell_1_0->GetTableCellRowIndex());
630 EXPECT_EQ(0, cell_1_0->GetTableCellColIndex());
631 AXNode* cell_1_1 = tree.GetFromId(7);
632 EXPECT_EQ(1, cell_1_1->GetTableCellRowIndex());
633 EXPECT_EQ(1, cell_1_1->GetTableCellColIndex());
634}

◆ TEST_F() [325/325]

ui::TEST_F ( AXTableInfoTest  ,
TableWithPartialIndices   
)

Definition at line 636 of file ax_table_info_unittest.cc.

636 {
637 // Start with a table with no indices.
638 AXTreeUpdate initial_state;
639 initial_state.root_id = 1;
640 initial_state.nodes.resize(7);
641 initial_state.nodes[0].id = 1;
642 initial_state.nodes[0].role = ax::mojom::Role::kTable;
643 initial_state.nodes[0].child_ids = {2, 3};
644 initial_state.nodes[1].id = 2;
645 initial_state.nodes[1].role = ax::mojom::Role::kRow;
646 initial_state.nodes[1].child_ids = {4, 5};
647 initial_state.nodes[2].id = 3;
648 initial_state.nodes[2].role = ax::mojom::Role::kRow;
649 initial_state.nodes[2].child_ids = {6, 7};
650 initial_state.nodes[3].id = 4;
651 initial_state.nodes[3].role = ax::mojom::Role::kColumnHeader;
652 initial_state.nodes[4].id = 5;
653 initial_state.nodes[4].role = ax::mojom::Role::kColumnHeader;
654 initial_state.nodes[5].id = 6;
655 initial_state.nodes[5].role = ax::mojom::Role::kCell;
656 initial_state.nodes[6].id = 7;
657 initial_state.nodes[6].role = ax::mojom::Role::kCell;
658
659 AXTree tree(initial_state);
660 AXNode* table = tree.root();
661
662 EXPECT_EQ(2, table->GetTableColCount());
663 EXPECT_EQ(2, table->GetTableRowCount());
664
665 AXNode* cell_0_0 = tree.GetFromId(4);
666 EXPECT_EQ(0, cell_0_0->GetTableCellRowIndex());
667 EXPECT_EQ(0, cell_0_0->GetTableCellColIndex());
668 AXNode* cell_0_1 = tree.GetFromId(5);
669 EXPECT_EQ(0, cell_0_1->GetTableCellRowIndex());
670 EXPECT_EQ(1, cell_0_1->GetTableCellColIndex());
671 AXNode* cell_1_0 = tree.GetFromId(6);
672 EXPECT_EQ(1, cell_1_0->GetTableCellRowIndex());
673 EXPECT_EQ(0, cell_1_0->GetTableCellColIndex());
674 AXNode* cell_1_1 = tree.GetFromId(7);
675 EXPECT_EQ(1, cell_1_1->GetTableCellRowIndex());
676 EXPECT_EQ(1, cell_1_1->GetTableCellColIndex());
677
678 AXTreeUpdate update = initial_state;
679 update.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kTableColumnCount,
680 5);
681 update.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kTableRowCount, 2);
683 2);
684 update.nodes[5].AddIntAttribute(
687 2);
688 update.nodes[6].AddIntAttribute(
690 EXPECT_TRUE(tree.Unserialize(update));
691
692 // The largest column index in the table is 2, but the
693 // table claims it has a column count of 5. That's allowed.
694 EXPECT_EQ(5, table->GetTableColCount());
695
696 // While the table claims it has a row count of 2, the
697 // last row has an index of 2, so the correct row count is 3.
698 EXPECT_EQ(3, table->GetTableRowCount());
699
700 EXPECT_EQ(2u, table->GetTableRowNodeIds().size());
701 EXPECT_EQ(2, table->GetTableRowNodeIds()[0]);
702 EXPECT_EQ(3, table->GetTableRowNodeIds()[1]);
703
704 // All of the specified row and cell indices are legal
705 // so they're respected.
706 EXPECT_EQ(0, cell_0_0->GetTableCellRowIndex());
707 EXPECT_EQ(0, cell_0_0->GetTableCellColIndex());
708 EXPECT_EQ(0, cell_0_1->GetTableCellRowIndex());
709 EXPECT_EQ(1, cell_0_1->GetTableCellColIndex());
710 EXPECT_EQ(2, cell_1_0->GetTableCellRowIndex());
711 EXPECT_EQ(0, cell_1_0->GetTableCellColIndex());
712 EXPECT_EQ(2, cell_1_1->GetTableCellRowIndex());
713 EXPECT_EQ(2, cell_1_1->GetTableCellColIndex());
714
715 // Fetching cells by coordinates works.
716 EXPECT_EQ(4, table->GetTableCellFromCoords(0, 0)->id());
717 EXPECT_EQ(5, table->GetTableCellFromCoords(0, 1)->id());
718 EXPECT_EQ(6, table->GetTableCellFromCoords(2, 0)->id());
719 EXPECT_EQ(7, table->GetTableCellFromCoords(2, 2)->id());
720 EXPECT_EQ(nullptr, table->GetTableCellFromCoords(0, 2));
721 EXPECT_EQ(nullptr, table->GetTableCellFromCoords(1, 0));
722 EXPECT_EQ(nullptr, table->GetTableCellFromCoords(1, 1));
723 EXPECT_EQ(nullptr, table->GetTableCellFromCoords(2, 1));
724}

◆ TEST_P() [1/4]

ui::TEST_P ( AXPositionCreatePositionAtTextBoundaryTestWithParam  ,
TextPositionBeforeStaticText   
)

Definition at line 7966 of file ax_node_position_unittest.cc.

7967 {
7969 GetTreeID(), static_text2_.id, 0 /* text_offset */,
7971 ASSERT_TRUE(text_position->IsTextPosition());
7972 text_position = text_position->CreatePositionAtTextBoundary(
7973 GetParam().boundary, GetParam().direction, GetParam().boundary_behavior);
7974 EXPECT_NE(nullptr, text_position);
7975 EXPECT_EQ(GetParam().expected_text_position, text_position->ToString());
7976}

◆ TEST_P() [2/4]

ui::TEST_P ( AXPositionExpandToEnclosingTextBoundaryTestWithParam  ,
TextPositionBeforeLine2   
)

Definition at line 7952 of file ax_node_position_unittest.cc.

7953 {
7954 // Create a text position right before "Line 2". This should be at the start
7955 // of many text boundaries, e.g. line, paragraph and word.
7957 GetTreeID(), text_field_.id, 7 /* text_offset */,
7959 ASSERT_TRUE(text_position->IsTextPosition());
7960 TestPositionRange range = text_position->ExpandToEnclosingTextBoundary(
7961 GetParam().boundary, GetParam().expand_behavior);
7962 EXPECT_EQ(GetParam().expected_anchor_position, range.anchor()->ToString());
7963 EXPECT_EQ(GetParam().expected_focus_position, range.focus()->ToString());
7964}
AXPositionType * anchor() const
Definition: ax_range.h:73
AXPositionType * focus() const
Definition: ax_range.h:78

◆ TEST_P() [3/4]

ui::TEST_P ( AXPositionTextNavigationTestWithParam  ,
TraverseTreeStartingWithAffinityDownstream   
)

Definition at line 7978 of file ax_node_position_unittest.cc.

7979 {
7981 GetTreeID(), GetParam().start_node_id, GetParam().start_offset,
7983 ASSERT_TRUE(text_position->IsTextPosition());
7984 for (const std::string& expectation : GetParam().expectations) {
7985 text_position = GetParam().TestMethod(text_position);
7986 EXPECT_NE(nullptr, text_position);
7987 EXPECT_EQ(expectation, text_position->ToString());
7988 }
7989}

◆ TEST_P() [4/4]

ui::TEST_P ( AXPositionTextNavigationTestWithParam  ,
TraverseTreeStartingWithAffinityUpstream   
)

Definition at line 7991 of file ax_node_position_unittest.cc.

7992 {
7994 GetTreeID(), GetParam().start_node_id, GetParam().start_offset,
7996 ASSERT_TRUE(text_position->IsTextPosition());
7997 for (const std::string& expectation : GetParam().expectations) {
7998 text_position = GetParam().TestMethod(text_position);
7999 EXPECT_NE(nullptr, text_position);
8000 EXPECT_EQ(expectation, text_position->ToString());
8001 }
8002}

◆ TestAXNodeDataSetter() [1/2]

template<typename T , typename U >
void ui::TestAXNodeDataSetter ( void(AXNodeData::*)(T, const U &)  Setter,
const U &  value 
)

Definition at line 50 of file ax_enum_util_unittest.cc.

51 {
52 AXNodeData node_data;
53 for (int i = static_cast<int>(T::kMinValue) + 1;
54 i <= static_cast<int>(T::kMaxValue); ++i) {
55 T attr = static_cast<T>(i);
56 ((node_data).*(Setter))(attr, value);
57 }
58 EXPECT_TRUE(!node_data.ToString().empty());
59}
#define T
Definition: precompiler.cc:65

◆ TestAXNodeDataSetter() [2/2]

template<typename T , typename U >
void ui::TestAXNodeDataSetter ( void(AXNodeData::*)(T, U)  Setter,
value 
)

Definition at line 64 of file ax_enum_util_unittest.cc.

64 {
65 AXNodeData node_data;
66 for (int i = static_cast<int>(T::kMinValue) + 1;
67 i <= static_cast<int>(T::kMaxValue); ++i) {
68 T attr = static_cast<T>(i);
69 ((node_data).*(Setter))(attr, value);
70 }
71 EXPECT_TRUE(!node_data.ToString().empty());
72}

◆ TestEnumStringConversion()

template<typename T >
void ui::TestEnumStringConversion ( T(ParseFunction)(const char *)  ,
int32_t(step)(int32_t)  = [](int32_t val) { return val + 1; } 
)

Definition at line 24 of file ax_enum_util_unittest.cc.

26 { return val + 1; }) {
27 // Check every valid enum value.
28 for (int i = static_cast<int>(T::kMinValue);
29 i <= static_cast<int>(T::kMaxValue); i = step(i)) {
30 T src = static_cast<T>(i);
31 std::string str = ToString(src);
32 auto dst = ParseFunction(str.c_str());
33 EXPECT_EQ(src, dst);
34 }
35
36 // Parse a bogus string.
37 EXPECT_EQ(T::kNone, ParseFunction("bogus"));
38
39 // Convert a bogus value to a string.
40 int out_of_range_value = static_cast<int>(T::kMaxValue) + 1;
41 EXPECT_STREQ("", ToString(static_cast<T>(out_of_range_value)));
42}
static int step(int x, SkScalar min, SkScalar max)
Definition: BlurTest.cpp:215
dst
Definition: cp.py:12

◆ ToLocalizedString()

AX_BASE_EXPORT std::string ui::ToLocalizedString ( ax::mojom::DefaultActionVerb  action_verb)

◆ ToString() [1/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::Action  action)

Definition at line 1114 of file ax_enum_util.cc.

1114 {
1115 switch (action) {
1117 return "none";
1119 return "blur";
1121 return "clearAccessibilityFocus";
1123 return "collapse";
1125 return "customAction";
1127 return "decrement";
1129 return "doDefault";
1131 return "expand";
1133 return "focus";
1135 return "getImageData";
1137 return "hitTest";
1139 return "increment";
1141 return "loadInlineTextBoxes";
1143 return "replaceSelectedText";
1145 return "scrollBackward";
1147 return "scrollForward";
1149 return "scrollUp";
1151 return "scrollDown";
1153 return "scrollLeft";
1155 return "scrollRight";
1157 return "scrollToMakeVisible";
1159 return "scrollToPoint";
1161 return "setAccessibilityFocus";
1163 return "setScrollOffset";
1165 return "setSelection";
1167 return "setSequentialFocusNavigationStartingPoint";
1169 return "setValue";
1171 return "showContextMenu";
1173 return "getTextLocation";
1175 return "annotatePageImages";
1177 return "signalEndOfTest";
1179 return "showTooltip";
1181 return "hideTooltip";
1183 return "internalInvalidateTree";
1184 }
1185
1186 return "";
1187}

◆ ToString() [2/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::ActionFlags  action_flags)

Definition at line 1261 of file ax_enum_util.cc.

1261 {
1262 switch (action_flags) {
1264 return "none";
1266 return "requestImages";
1268 return "requestInlineTextBoxes";
1269 }
1270
1271 return "";
1272}

◆ ToString() [3/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::AriaCurrentState  aria_current_state)

Definition at line 2413 of file ax_enum_util.cc.

2413 {
2414 switch (aria_current_state) {
2416 return "none";
2418 return "false";
2420 return "true";
2422 return "page";
2424 return "step";
2426 return "location";
2428 return "unclippedLocation";
2430 return "date";
2432 return "time";
2433 }
2434
2435 return "";
2436}

◆ ToString() [4/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::BoolAttribute  bool_attribute)

Definition at line 1825 of file ax_enum_util.cc.

1825 {
1826 switch (bool_attribute) {
1828 return "none";
1830 return "busy";
1832 return "editableRoot";
1834 return "containerLiveAtomic";
1836 return "containerLiveBusy";
1838 return "grabbed";
1840 return "liveAtomic";
1842 return "modal";
1844 return "updateLocationOnly";
1846 return "canvasHasFallback";
1848 return "scrollable";
1850 return "clickable";
1852 return "clipsChildren";
1854 return "notUserSelectableStyle";
1856 return "selected";
1858 return "selectedFromFocus";
1860 return "supportsTextLocation";
1862 return "isLineBreakingObject";
1864 return "isPageBreakingObject";
1866 return "hasAriaAttribute";
1867 }
1868
1869 return "";
1870}

◆ ToString() [5/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::CheckedState  checked_state)

Definition at line 2549 of file ax_enum_util.cc.

2549 {
2550 switch (checked_state) {
2552 return "none";
2554 return "false";
2556 return "true";
2558 return "mixed";
2559 }
2560
2561 return "";
2562}

◆ ToString() [6/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::Command  command)

Definition at line 2105 of file ax_enum_util.cc.

2105 {
2106 switch (command) {
2108 return "clearSelection";
2110 return "cut";
2112 return "delete";
2114 return "dictate";
2116 return "extendSelection";
2118 return "format";
2120 return "insert";
2122 return "marker";
2124 return "moveSelection";
2126 return "paste";
2128 return "replace";
2130 return "setSelection";
2132 return "type";
2133 }
2134
2135 return "";
2136}

◆ ToString() [7/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::DefaultActionVerb  default_action_verb)

Definition at line 1321 of file ax_enum_util.cc.

1321 {
1322 switch (default_action_verb) {
1324 return "none";
1326 return "activate";
1328 return "check";
1330 return "click";
1332 // Some screen readers, such as Jaws, expect the following spelling of
1333 // this verb.
1334 return "click-ancestor";
1336 return "jump";
1338 return "open";
1340 return "press";
1342 return "select";
1344 return "uncheck";
1345 }
1346
1347 return "";
1348}

◆ ToString() [8/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::DescriptionFrom  description_from)

Definition at line 2658 of file ax_enum_util.cc.

2658 {
2659 switch (description_from) {
2661 return "none";
2663 return "uninitialized";
2665 return "attribute";
2667 return "contents";
2669 return "relatedElement";
2671 return "title";
2672 }
2673
2674 return "";
2675}

◆ ToString() [9/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::Dropeffect  dropeffect)

Definition at line 2926 of file ax_enum_util.cc.

2926 {
2927 switch (dropeffect) {
2929 return "copy";
2931 return "execute";
2933 return "link";
2935 return "move";
2937 return "popup";
2939 return "none";
2940 }
2941
2942 return "";
2943}

◆ ToString() [10/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::Event  event)

Definition at line 9 of file ax_enum_util.cc.

9 {
10 switch (event) {
12 return "none";
14 return "activedescendantchanged";
16 return "alert";
18 return "ariaAttributeChanged";
20 return "autocorrectionOccured";
22 return "blur";
24 return "checkedStateChanged";
26 return "childrenChanged";
28 return "clicked";
30 return "controlsChanged";
32 return "documentSelectionChanged";
34 return "documentTitleChanged";
36 return "endOfTest";
38 return "expandedChanged";
40 return "focus";
42 return "focusAfterMenuClose";
44 return "focusContext";
46 return "hide";
48 return "hitTestResult";
50 return "hover";
52 return "imageFrameUpdated";
54 return "invalidStatusChanged";
56 return "layoutComplete";
58 return "liveRegionCreated";
60 return "liveRegionChanged";
62 return "loadComplete";
64 return "loadStart";
66 return "locationChanged";
68 return "mediaStartedPlaying";
70 return "mediaStoppedPlaying";
72 return "menuEnd";
74 return "menuListItemSelected";
76 return "menuListValueChanged";
78 return "menuPopupEnd";
80 return "menuPopupStart";
82 return "menuStart";
84 return "mouseCanceled";
86 return "mouseDragged";
88 return "mouseMoved";
90 return "mousePressed";
92 return "mouseReleased";
94 return "rowCollapsed";
96 return "rowCountChanged";
98 return "rowExpanded";
100 return "scrollPositionChanged";
102 return "scrolledToAnchor";
104 return "selectedChildrenChanged";
106 return "selection";
108 return "selectionAdd";
110 return "selectionRemove";
112 return "show";
114 return "stateChanged";
116 return "textChanged";
118 return "textSelectionChanged";
120 return "tooltipClosed";
122 return "tooltipOpened";
124 return "windowActivated";
126 return "windowDeactivated";
128 return "windowVisibilityChanged";
130 return "treeChanged";
132 return "valueChanged";
133 }
134
135 return "";
136}

◆ ToString() [11/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::EventFrom  event_from)

Definition at line 2693 of file ax_enum_util.cc.

2693 {
2694 switch (event_from) {
2696 return "none";
2698 return "user";
2700 return "page";
2702 return "action";
2703 }
2704
2705 return "";
2706}

◆ ToString() [12/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::FloatAttribute  float_attribute)

Definition at line 1782 of file ax_enum_util.cc.

1782 {
1783 switch (float_attribute) {
1785 return "none";
1787 return "valueForRange";
1789 return "minValueForRange";
1791 return "maxValueForRange";
1793 return "stepValueForRange";
1795 return "fontSize";
1797 return "fontWeight";
1799 return "textIndent";
1800 }
1801
1802 return "";
1803}

◆ ToString() [13/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::Gesture  gesture)

Definition at line 2720 of file ax_enum_util.cc.

2720 {
2721 switch (gesture) {
2723 return "none";
2725 return "click";
2727 return "swipeLeft1";
2729 return "swipeUp1";
2731 return "swipeRight1";
2733 return "swipeDown1";
2735 return "swipeLeft2";
2737 return "swipeUp2";
2739 return "swipeRight2";
2741 return "swipeDown2";
2743 return "swipeLeft3";
2745 return "swipeUp3";
2747 return "swipeRight3";
2749 return "swipeDown3";
2751 return "swipeLeft4";
2753 return "swipeUp4";
2755 return "swipeRight4";
2757 return "swipeDown4";
2759 return "tap2";
2761 return "tap3";
2763 return "tap4";
2765 return "touchExplore";
2766 }
2767
2768 return "";
2769}

◆ ToString() [14/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::HasPopup  has_popup)

Definition at line 2461 of file ax_enum_util.cc.

2461 {
2462 switch (has_popup) {
2464 return "";
2466 return "true";
2468 return "menu";
2470 return "listbox";
2472 return "tree";
2474 return "grid";
2476 return "dialog";
2477 }
2478
2479 return "";
2480}

◆ ToString() [15/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::ImageAnnotationStatus  status)

Definition at line 2873 of file ax_enum_util.cc.

2873 {
2874 switch (status) {
2876 return "none";
2878 return "kWillNotAnnotateDueToScheme";
2880 return "ineligibleForAnnotation";
2882 return "eligibleForAnnotation";
2884 return "silentlyEligibleForAnnotation";
2886 return "annotationPending";
2888 return "annotationSucceeded";
2890 return "annotationEmpty";
2892 return "annotationAdult";
2894 return "annotationProcessFailed";
2895 }
2896
2897 return "";
2898}

◆ ToString() [16/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::IntAttribute  int_attribute)

Definition at line 1527 of file ax_enum_util.cc.

1527 {
1528 switch (int_attribute) {
1530 return "none";
1532 return "defaultActionVerb";
1534 return "dropeffect";
1536 return "scrollX";
1538 return "scrollXMin";
1540 return "scrollXMax";
1542 return "scrollY";
1544 return "scrollYMin";
1546 return "scrollYMax";
1548 return "textSelStart";
1550 return "textSelEnd";
1552 return "ariaColumnCount";
1554 return "ariaCellColumnIndex";
1556 return "ariaCellColumnSpan";
1558 return "ariaRowCount";
1560 return "ariaCellRowIndex";
1562 return "ariaCellRowSpan";
1564 return "tableRowCount";
1566 return "tableColumnCount";
1568 return "tableHeaderId";
1570 return "tableRowIndex";
1572 return "tableRowHeaderId";
1574 return "tableColumnIndex";
1576 return "tableColumnHeaderId";
1578 return "tableCellColumnIndex";
1580 return "tableCellColumnSpan";
1582 return "tableCellRowIndex";
1584 return "tableCellRowSpan";
1586 return "sortDirection";
1588 return "hierarchicalLevel";
1590 return "nameFrom";
1592 return "descriptionFrom";
1594 return "activedescendantId";
1596 return "errormessageId";
1598 return "inPageLinkTargetId";
1600 return "memberOfId";
1602 return "nextOnLineId";
1604 return "popupForId";
1606 return "previousOnLineId";
1608 return "restriction";
1610 return "setSize";
1612 return "posInSet";
1614 return "colorValue";
1616 return "ariaCurrentState";
1618 return "backgroundColor";
1620 return "color";
1622 return "haspopup";
1624 return "invalidState";
1626 return "checkedState";
1628 return "listStyle";
1630 return "text-align";
1632 return "textDirection";
1634 return "textPosition";
1636 return "textStyle";
1638 return "textOverlineStyle";
1640 return "textStrikethroughStyle";
1642 return "textUnderlineStyle";
1644 return "previousFocusId";
1646 return "nextFocusId";
1648 return "imageAnnotationStatus";
1650 return "domNodeId";
1651 }
1652
1653 return "";
1654}

◆ ToString() [17/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::IntListAttribute  int_list_attribute)

Definition at line 1916 of file ax_enum_util.cc.

1916 {
1917 switch (int_list_attribute) {
1919 return "none";
1921 return "indirectChildIds";
1923 return "controlsIds";
1925 return "detailsIds";
1927 return "describedbyIds";
1929 return "flowtoIds";
1931 return "labelledbyIds";
1933 return "radioGroupIds";
1935 return "markerTypes";
1937 return "markerStarts";
1939 return "markerEnds";
1941 return "characterOffsets";
1943 return "cachedLineStarts";
1945 return "wordStarts";
1947 return "wordEnds";
1949 return "customActionIds";
1950 }
1951
1952 return "";
1953}

◆ ToString() [18/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::InvalidState  invalid_state)

Definition at line 2499 of file ax_enum_util.cc.

2499 {
2500 switch (invalid_state) {
2502 return "none";
2504 return "false";
2506 return "true";
2508 return "other";
2509 }
2510
2511 return "";
2512}

◆ ToString() [19/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::ListStyle  list_style)

Definition at line 2012 of file ax_enum_util.cc.

2012 {
2013 switch (list_style) {
2015 return "none";
2017 return "circle";
2019 return "disc";
2021 return "image";
2023 return "numeric";
2025 return "other";
2027 return "square";
2028 }
2029
2030 return "";
2031}

◆ ToString() [20/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::MarkerType  marker_type)

Definition at line 2051 of file ax_enum_util.cc.

2051 {
2052 switch (marker_type) {
2054 return "none";
2056 return "spelling";
2058 return "grammar";
2060 return "textMatch";
2062 return "activeSuggestion";
2064 return "suggestion";
2065 }
2066
2067 return "";
2068}

◆ ToString() [21/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::MoveDirection  move_direction)

Definition at line 2086 of file ax_enum_util.cc.

2086 {
2087 switch (move_direction) {
2089 return "forward";
2091 return "backward";
2092 }
2093
2094 return "";
2095}

◆ ToString() [22/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::Mutation  mutation)

Definition at line 1377 of file ax_enum_util.cc.

1377 {
1378 switch (mutation) {
1380 return "none";
1382 return "nodeCreated";
1384 return "subtreeCreated";
1386 return "nodeChanged";
1388 return "nodeRemoved";
1389 }
1390
1391 return "";
1392}

◆ ToString() [23/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::NameFrom  name_from)

Definition at line 2607 of file ax_enum_util.cc.

2607 {
2608 switch (name_from) {
2610 return "none";
2612 return "uninitialized";
2614 return "attribute";
2616 return "attributeExplicitlyEmpty";
2618 return "caption";
2620 return "contents";
2622 return "placeholder";
2624 return "relatedElement";
2626 return "title";
2628 return "value";
2629 }
2630
2631 return "";
2632}

◆ ToString() [24/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::Restriction  restriction)

Definition at line 2526 of file ax_enum_util.cc.

2526 {
2527 switch (restriction) {
2529 return "none";
2531 return "readOnly";
2533 return "disabled";
2534 }
2535
2536 return "";
2537}

◆ ToString() [25/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::Role  role)

Definition at line 264 of file ax_enum_util.cc.

264 {
265 switch (role) {
267 return "none";
269 return "abbr";
271 return "alertDialog";
273 return "alert";
275 return "anchor";
277 return "application";
279 return "article";
281 return "audio";
283 return "banner";
285 return "blockquote";
287 return "button";
289 return "canvas";
291 return "caption";
293 return "caret";
295 return "cell";
297 return "checkBox";
299 return "client";
301 return "code";
303 return "colorWell";
305 return "columnHeader";
307 return "column";
309 return "comboBoxGrouping";
311 return "comboBoxMenuButton";
313 return "comment";
315 return "complementary";
317 return "contentDeletion";
319 return "contentInsertion";
321 return "contentInfo";
323 return "date";
325 return "dateTime";
327 return "definition";
329 return "descriptionListDetail";
331 return "descriptionList";
333 return "descriptionListTerm";
335 return "desktop";
337 return "details";
339 return "dialog";
341 return "directory";
343 return "disclosureTriangle";
345 return "docAbstract";
347 return "docAcknowledgments";
349 return "docAfterword";
351 return "docAppendix";
353 return "docBackLink";
355 return "docBiblioEntry";
357 return "docBibliography";
359 return "docBiblioRef";
361 return "docChapter";
363 return "docColophon";
365 return "docConclusion";
367 return "docCover";
369 return "docCredit";
371 return "docCredits";
373 return "docDedication";
375 return "docEndnote";
377 return "docEndnotes";
379 return "docEpigraph";
381 return "docEpilogue";
383 return "docErrata";
385 return "docExample";
387 return "docFootnote";
389 return "docForeword";
391 return "docGlossary";
393 return "docGlossref";
395 return "docIndex";
397 return "docIntroduction";
399 return "docNoteRef";
401 return "docNotice";
403 return "docPageBreak";
405 return "docPageList";
407 return "docPart";
409 return "docPreface";
411 return "docPrologue";
413 return "docPullquote";
415 return "docQna";
417 return "docSubtitle";
419 return "docTip";
421 return "docToc";
423 return "document";
425 return "embeddedObject";
427 return "emphasis";
429 return "feed";
431 return "figcaption";
433 return "figure";
435 return "footer";
437 return "footerAsNonLandmark";
439 return "form";
441 return "genericContainer";
443 return "graphicsDocument";
445 return "graphicsObject";
447 return "graphicsSymbol";
449 return "grid";
451 return "group";
453 return "header";
455 return "headerAsNonLandmark";
457 return "heading";
459 return "iframe";
461 return "iframePresentational";
463 return "ignored";
465 return "imageMap";
467 return "image";
469 return "imeCandidate";
471 return "inlineTextBox";
473 return "inputTime";
475 return "keyboard";
477 return "labelText";
479 return "layoutTable";
481 return "layoutTableCell";
483 return "layoutTableRow";
485 return "legend";
487 return "lineBreak";
489 return "link";
491 return "list";
493 return "listBoxOption";
495 return "listBox";
497 return "listGrid";
499 return "listItem";
501 return "listMarker";
503 return "log";
505 return "main";
507 return "mark";
509 return "marquee";
511 return "math";
513 return "menu";
515 return "menuBar";
517 return "menuItem";
519 return "menuItemCheckBox";
521 return "menuItemRadio";
523 return "menuListOption";
525 return "menuListPopup";
527 return "meter";
529 return "navigation";
531 return "note";
533 return "pane";
535 return "paragraph";
537 return "pdfActionableHighlight";
539 return "pluginObject";
541 return "popUpButton";
543 return "portal";
545 return "pre";
547 return "presentational";
549 return "progressIndicator";
551 return "radioButton";
553 return "radioGroup";
555 return "region";
557 return "rootWebArea";
559 return "row";
561 return "rowGroup";
563 return "rowHeader";
565 return "ruby";
567 return "rubyAnnotation";
569 return "section";
571 return "strong";
573 return "suggestion";
575 return "svgRoot";
577 return "scrollBar";
579 return "scrollView";
581 return "search";
583 return "searchBox";
585 return "slider";
587 return "sliderThumb";
589 return "spinButton";
591 return "splitter";
593 return "staticText";
595 return "status";
597 return "switch";
599 return "tabList";
601 return "tabPanel";
603 return "tab";
605 return "table";
607 return "tableHeaderContainer";
609 return "term";
611 return "textField";
613 return "textFieldWithComboBox";
615 return "time";
617 return "timer";
619 return "titleBar";
621 return "toggleButton";
623 return "toolbar";
625 return "treeGrid";
627 return "treeItem";
629 return "tree";
631 return "unknown";
633 return "tooltip";
635 return "video";
637 return "webArea";
639 return "webView";
641 return "window";
642 }
643
644 return "";
645}

◆ ToString() [26/39]

const char * ui::ToString ( ax::mojom::ScrollAlignment  scroll_alignment)

Definition at line 1284 of file ax_enum_util.cc.

1284 {
1285 switch (scroll_alignment) {
1287 return "none";
1289 return "scrollAlignmentCenter";
1291 return "scrollAlignmentTop";
1293 return "scrollAlignmentBottom";
1295 return "scrollAlignmentLeft";
1297 return "scrollAlignmentRight";
1299 return "scrollAlignmentClosestEdge";
1300 }
1301}

◆ ToString() [27/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::SortDirection  sort_direction)

Definition at line 2576 of file ax_enum_util.cc.

2576 {
2577 switch (sort_direction) {
2579 return "none";
2581 return "unsorted";
2583 return "ascending";
2585 return "descending";
2587 return "other";
2588 }
2589
2590 return "";
2591}

◆ ToString() [28/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::State  state)

Definition at line 1027 of file ax_enum_util.cc.

1027 {
1028 switch (state) {
1030 return "none";
1032 return "autofillAvailable";
1034 return "collapsed";
1036 return "default";
1038 return "editable";
1040 return "expanded";
1042 return "focusable";
1044 return "horizontal";
1046 return "hovered";
1048 return "ignored";
1050 return "invisible";
1052 return "linked";
1054 return "multiline";
1056 return "multiselectable";
1058 return "protected";
1060 return "required";
1062 return "richlyEditable";
1064 return "vertical";
1066 return "visited";
1067 }
1068
1069 return "";
1070}

◆ ToString() [29/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::StringAttribute  string_attribute)

Definition at line 1408 of file ax_enum_util.cc.

1408 {
1409 switch (string_attribute) {
1411 return "none";
1413 return "accessKey";
1415 return "ariaInvalidValue";
1417 return "autoComplete";
1419 return "childTreeId";
1421 return "className";
1423 return "containerLiveRelevant";
1425 return "containerLiveStatus";
1427 return "description";
1429 return "display";
1431 return "fontFamily";
1433 return "htmlTag";
1435 return "imageAnnotation";
1437 return "imageDataUrl";
1439 return "innerHtml";
1441 return "inputType";
1443 return "keyShortcuts";
1445 return "language";
1447 return "name";
1449 return "liveRelevant";
1451 return "liveStatus";
1453 return "placeholder";
1455 return "role";
1457 return "roleDescription";
1459 return "tooltip";
1461 return "url";
1463 return "value";
1464 }
1465
1466 return "";
1467}

◆ ToString() [30/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::StringListAttribute  string_list_attribute)

Definition at line 1992 of file ax_enum_util.cc.

1992 {
1993 switch (string_list_attribute) {
1995 return "none";
1997 return "customActionDescriptions";
1998 }
1999
2000 return "";
2001}

◆ ToString() [31/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::TextAffinity  text_affinity)

Definition at line 2819 of file ax_enum_util.cc.

2819 {
2820 switch (text_affinity) {
2822 return "none";
2824 return "downstream";
2826 return "upstream";
2827 }
2828
2829 return "";
2830}

◆ ToString() [32/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::TextAlign  text_align)

Definition at line 2293 of file ax_enum_util.cc.

2293 {
2294 switch (text_align) {
2296 return "none";
2298 return "left";
2300 return "right";
2302 return "center";
2304 return "justify";
2305 }
2306
2307 return "";
2308}

◆ ToString() [33/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::TextBoundary  text_boundary)

Definition at line 2170 of file ax_enum_util.cc.

2170 {
2171 switch (text_boundary) {
2173 return "character";
2175 return "format";
2177 return "lineEnd";
2179 return "lineStart";
2181 return "lineStartOrEnd";
2183 return "object";
2185 return "pageEnd";
2187 return "pageStart";
2189 return "pageStartOrEnd";
2191 return "paragraphEnd";
2193 return "paragraphStart";
2195 return "paragraphStartOrEnd";
2197 return "sentenceEnd";
2199 return "sentenceStart";
2201 return "sentenceStartOrEnd";
2203 return "webPage";
2205 return "wordEnd";
2207 return "wordStart";
2209 return "wordStartOrEnd";
2210 }
2211
2212 return "";
2213}

◆ ToString() [34/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::TextDecorationStyle  text_decoration_style)

Definition at line 2257 of file ax_enum_util.cc.

2257 {
2258 switch (text_decoration_style) {
2260 return "none";
2262 return "solid";
2264 return "dashed";
2266 return "dotted";
2268 return "double";
2270 return "wavy";
2271 }
2272
2273 return "";
2274}

◆ ToString() [35/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::TextPosition  text_position)

Definition at line 2355 of file ax_enum_util.cc.

2355 {
2356 switch (text_position) {
2358 return "none";
2360 return "subscript";
2362 return "superscript";
2363 }
2364
2365 return "";
2366}

◆ ToString() [36/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::TextStyle  text_style)

Definition at line 2378 of file ax_enum_util.cc.

2378 {
2379 switch (text_style) {
2381 return "none";
2383 return "bold";
2385 return "italic";
2387 return "underline";
2389 return "lineThrough";
2391 return "overline";
2392 }
2393
2394 return "";
2395}

◆ ToString() [37/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::TreeOrder  tree_order)

Definition at line 2842 of file ax_enum_util.cc.

2842 {
2843 switch (tree_order) {
2845 return "none";
2847 return "undefined";
2849 return "before";
2851 return "equal";
2853 return "after";
2854 }
2855
2856 return "";
2857}

◆ ToString() [38/39]

AX_BASE_EXPORT const char * ui::ToString ( ax::mojom::WritingDirection  text_direction)

Definition at line 2324 of file ax_enum_util.cc.

2324 {
2325 switch (text_direction) {
2327 return "none";
2329 return "ltr";
2331 return "rtl";
2333 return "ttb";
2335 return "btt";
2336 }
2337
2338 return "";
2339}

◆ ToString() [39/39]

AX_EXPORT const char * ui::ToString ( AXEventGenerator::Event  event)

Definition at line 921 of file ax_event_generator.cc.

921 {
922 switch (event) {
923 case AXEventGenerator::Event::ACCESS_KEY_CHANGED:
924 return "ACCESS_KEY_CHANGED";
925 case AXEventGenerator::Event::ATOMIC_CHANGED:
926 return "ATOMIC_CHANGED";
927 case AXEventGenerator::Event::ACTIVE_DESCENDANT_CHANGED:
928 return "ACTIVE_DESCENDANT_CHANGED";
929 case AXEventGenerator::Event::ALERT:
930 return "ALERT";
931 case AXEventGenerator::Event::ATK_TEXT_OBJECT_ATTRIBUTE_CHANGED:
932 return "ATK_TEXT_OBJECT_ATTRIBUTE_CHANGED";
933 case AXEventGenerator::Event::BUSY_CHANGED:
934 return "BUSY_CHANGED";
935 case AXEventGenerator::Event::CHECKED_STATE_CHANGED:
936 return "CHECKED_STATE_CHANGED";
937 case AXEventGenerator::Event::CHILDREN_CHANGED:
938 return "CHILDREN_CHANGED";
939 case AXEventGenerator::Event::CLASS_NAME_CHANGED:
940 return "CLASS_NAME_CHANGED";
941 case AXEventGenerator::Event::COLLAPSED:
942 return "COLLAPSED";
943 case AXEventGenerator::Event::CONTROLS_CHANGED:
944 return "CONTROLS_CHANGED";
945 case AXEventGenerator::Event::DESCRIBED_BY_CHANGED:
946 return "DESCRIBED_BY_CHANGED";
947 case AXEventGenerator::Event::DESCRIPTION_CHANGED:
948 return "DESCRIPTION_CHANGED";
949 case AXEventGenerator::Event::DOCUMENT_SELECTION_CHANGED:
950 return "DOCUMENT_SELECTION_CHANGED";
951 case AXEventGenerator::Event::DOCUMENT_TITLE_CHANGED:
952 return "DOCUMENT_TITLE_CHANGED";
953 case AXEventGenerator::Event::DROPEFFECT_CHANGED:
954 return "DROPEFFECT_CHANGED";
955 case AXEventGenerator::Event::ENABLED_CHANGED:
956 return "ENABLED_CHANGED";
957 case AXEventGenerator::Event::EXPANDED:
958 return "EXPANDED";
959 case AXEventGenerator::Event::FLOW_FROM_CHANGED:
960 return "FLOW_FROM_CHANGED";
961 case AXEventGenerator::Event::FLOW_TO_CHANGED:
962 return "FLOW_TO_CHANGED";
963 case AXEventGenerator::Event::GRABBED_CHANGED:
964 return "GRABBED_CHANGED";
965 case AXEventGenerator::Event::HASPOPUP_CHANGED:
966 return "HASPOPUP_CHANGED";
967 case AXEventGenerator::Event::HIERARCHICAL_LEVEL_CHANGED:
968 return "HIERARCHICAL_LEVEL_CHANGED";
970 return "IGNORED_CHANGED";
971 case AXEventGenerator::Event::IMAGE_ANNOTATION_CHANGED:
972 return "IMAGE_ANNOTATION_CHANGED";
973 case AXEventGenerator::Event::INVALID_STATUS_CHANGED:
974 return "INVALID_STATUS_CHANGED";
975 case AXEventGenerator::Event::KEY_SHORTCUTS_CHANGED:
976 return "KEY_SHORTCUTS_CHANGED";
977 case AXEventGenerator::Event::LABELED_BY_CHANGED:
978 return "LABELED_BY_CHANGED";
979 case AXEventGenerator::Event::LANGUAGE_CHANGED:
980 return "LANGUAGE_CHANGED";
981 case AXEventGenerator::Event::LAYOUT_INVALIDATED:
982 return "LAYOUT_INVALIDATED";
983 case AXEventGenerator::Event::LIVE_REGION_CHANGED:
984 return "LIVE_REGION_CHANGED";
985 case AXEventGenerator::Event::LIVE_REGION_CREATED:
986 return "LIVE_REGION_CREATED";
987 case AXEventGenerator::Event::LIVE_REGION_NODE_CHANGED:
988 return "LIVE_REGION_NODE_CHANGED";
989 case AXEventGenerator::Event::LIVE_RELEVANT_CHANGED:
990 return "LIVE_RELEVANT_CHANGED";
991 case AXEventGenerator::Event::LIVE_STATUS_CHANGED:
992 return "LIVE_STATUS_CHANGED";
993 case AXEventGenerator::Event::LOAD_COMPLETE:
994 return "LOAD_COMPLETE";
995 case AXEventGenerator::Event::LOAD_START:
996 return "LOAD_START";
997 case AXEventGenerator::Event::MENU_ITEM_SELECTED:
998 return "MENU_ITEM_SELECTED";
999 case AXEventGenerator::Event::MULTILINE_STATE_CHANGED:
1000 return "MULTILINE_STATE_CHANGED";
1001 case AXEventGenerator::Event::MULTISELECTABLE_STATE_CHANGED:
1002 return "MULTISELECTABLE_STATE_CHANGED";
1003 case AXEventGenerator::Event::NAME_CHANGED:
1004 return "NAME_CHANGED";
1005 case AXEventGenerator::Event::OBJECT_ATTRIBUTE_CHANGED:
1006 return "OBJECT_ATTRIBUTE_CHANGED";
1007 case AXEventGenerator::Event::OTHER_ATTRIBUTE_CHANGED:
1008 return "OTHER_ATTRIBUTE_CHANGED";
1009 case AXEventGenerator::Event::PLACEHOLDER_CHANGED:
1010 return "PLACEHOLDER_CHANGED";
1011 case AXEventGenerator::Event::PORTAL_ACTIVATED:
1012 return "PORTAL_ACTIVATED";
1013 case AXEventGenerator::Event::POSITION_IN_SET_CHANGED:
1014 return "POSITION_IN_SET_CHANGED";
1015 case AXEventGenerator::Event::READONLY_CHANGED:
1016 return "READONLY_CHANGED";
1017 case AXEventGenerator::Event::RELATED_NODE_CHANGED:
1018 return "RELATED_NODE_CHANGED";
1019 case AXEventGenerator::Event::REQUIRED_STATE_CHANGED:
1020 return "REQUIRED_STATE_CHANGED";
1021 case AXEventGenerator::Event::ROLE_CHANGED:
1022 return "ROLE_CHANGED";
1023 case AXEventGenerator::Event::ROW_COUNT_CHANGED:
1024 return "ROW_COUNT_CHANGED";
1025 case AXEventGenerator::Event::SCROLL_HORIZONTAL_POSITION_CHANGED:
1026 return "SCROLL_HORIZONTAL_POSITION_CHANGED";
1027 case AXEventGenerator::Event::SCROLL_VERTICAL_POSITION_CHANGED:
1028 return "SCROLL_VERTICAL_POSITION_CHANGED";
1029 case AXEventGenerator::Event::SELECTED_CHANGED:
1030 return "SELECTED_CHANGED";
1031 case AXEventGenerator::Event::SELECTED_CHILDREN_CHANGED:
1032 return "SELECTED_CHILDREN_CHANGED";
1033 case AXEventGenerator::Event::SET_SIZE_CHANGED:
1034 return "SET_SIZE_CHANGED";
1035 case AXEventGenerator::Event::STATE_CHANGED:
1036 return "STATE_CHANGED";
1037 case AXEventGenerator::Event::SUBTREE_CREATED:
1038 return "SUBTREE_CREATED";
1039 case AXEventGenerator::Event::TEXT_ATTRIBUTE_CHANGED:
1040 return "TEXT_ATTRIBUTE_CHANGED";
1041 case AXEventGenerator::Event::VALUE_CHANGED:
1042 return "VALUE_CHANGED";
1043 case AXEventGenerator::Event::VALUE_MAX_CHANGED:
1044 return "VALUE_MAX_CHANGED";
1045 case AXEventGenerator::Event::VALUE_MIN_CHANGED:
1046 return "VALUE_MIN_CHANGED";
1047 case AXEventGenerator::Event::VALUE_STEP_CHANGED:
1048 return "VALUE_STEP_CHANGED";
1049 case AXEventGenerator::Event::AUTO_COMPLETE_CHANGED:
1050 return "AUTO_COMPLETE_CHANGED";
1051 case AXEventGenerator::Event::FOCUS_CHANGED:
1052 return "FOCUS_CHANGED";
1053 case AXEventGenerator::Event::SORT_CHANGED:
1054 return "SORT_CHANGED";
1055 case AXEventGenerator::Event::WIN_IACCESSIBLE_STATE_CHANGED:
1056 return "WIN_IACCESSIBLE_STATE_CHANGED";
1057 }
1059}

◆ TreeUpdatesCanBeMerged()

template<typename AXNodeData , typename AXTreeData >
bool ui::TreeUpdatesCanBeMerged ( const AXTreeUpdateBase< AXNodeData, AXTreeData > &  u1,
const AXTreeUpdateBase< AXNodeData, AXTreeData > &  u2 
)

Definition at line 137 of file ax_tree_update.h.

139 {
140 if (u2.node_id_to_clear != AXNode::kInvalidAXID)
141 return false;
142
143 if (u2.has_tree_data && u2.tree_data != u1.tree_data)
144 return false;
145
146 if (u2.root_id != u1.root_id)
147 return false;
148
149 return true;
150}

Variable Documentation

◆ g_active_popup_ax_unique_id

std::optional<int32_t> ui::g_active_popup_ax_unique_id
static

Definition at line 15 of file ax_active_popup.cc.

◆ g_ax_embedded_object_behavior

AX_EXPORT AXEmbeddedObjectBehavior ui::g_ax_embedded_object_behavior
Initial value:
=
AXEmbeddedObjectBehavior::kSuppressCharacter

Definition at line 16 of file ax_node_position.cc.

◆ g_unique_id_map

UniqueIdMap ui::g_unique_id_map

Definition at line 63 of file ax_platform_node_base.cc.

◆ kMaxId

const int32_t ui::kMaxId = 100
static

Definition at line 19 of file ax_unique_id_unittest.cc.

◆ kScreenReaderAndHTMLAccessibilityModes

const uint32_t ui::kScreenReaderAndHTMLAccessibilityModes
Initial value:
=
AXMode::kScreenReader | AXMode::kHTML

Definition at line 247 of file ax_platform_node_win.cc.

◆ kUiaEventTestCompleteSentinelGuid

const GUID ui::kUiaEventTestCompleteSentinelGuid
static
Initial value:
= {
0x3761326a,
0x34b2,
0x465a,
{0x83, 0x5d, 0x7a, 0x3d, 0x8f, 0x4e, 0xfb, 0x92}}

Definition at line 16 of file uia_registrar_win.h.

◆ kUiaPropertyUniqueIdGuid

const GUID ui::kUiaPropertyUniqueIdGuid
static
Initial value:
= {
0xcc7eeb32,
0x4b62,
0x4f4c,
{0xaf, 0xf6, 0x1c, 0x2e, 0x57, 0x52, 0xad, 0x8e}}

Definition at line 23 of file uia_registrar_win.h.