Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
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)
 
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

◆ 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};

◆ 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()

◆ 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

References 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

References ui::AXPlatformNodeDelegate::IsOrderedSet(), ui::AXPlatformNodeDelegate::IsOrderedSetItem(), ui::AXPlatformNodeDelegate::IsTable(), ui::AXPlatformNodeDelegate::IsTableCellOrHeader(), and ui::AXPlatformNodeDelegate::IsTableRow().

Referenced by ui::AXPlatformNodeBase::AddAttributeToList().

◆ 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 {
229 return AXNodePosition::CreateTextPosition(anchor.tree()->GetAXTreeID(),
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

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXNode::OwnerTree::GetAXTreeID(), ui::AXNode::id(), and ui::AXNode::tree().

Referenced by ui::AXPlatformNodeTextRangeProviderTest::CreateTextRangeProviderWin().

◆ GetActivePopupAxUniqueId()

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

Definition at line 17 of file ax_active_popup.cc.

17 {
19}

References g_active_popup_ax_unique_id.

Referenced by SetActivePopupAxUniqueId().

◆ 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}

References ax::mojom::kErrormessageId, ax::mojom::kMemberOfId, and ax::mojom::kPopupForId.

Referenced by ui::AXPlatformRelationWin::EnumerateRelationships().

◆ 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}

References ax::mojom::kControlsIds, ax::mojom::kDescribedbyIds, ax::mojom::kDetailsIds, ax::mojom::kFlowtoIds, and ax::mojom::kLabelledbyIds.

Referenced by ui::AXPlatformRelationWin::EnumerateRelationships().

◆ 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}

References ax::mojom::kErrormessageId.

Referenced by ui::AXPlatformRelationWin::EnumerateRelationships().

◆ 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}

References ax::mojom::kControlsIds, ax::mojom::kDescribedbyIds, ax::mojom::kDetailsIds, ax::mojom::kFlowtoIds, and ax::mojom::kLabelledbyIds.

Referenced by ui::AXPlatformRelationWin::EnumerateRelationships().

◆ HasPresentationalChildren()

AX_BASE_EXPORT bool ui::HasPresentationalChildren ( 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"}})   
)

References CrossBoundary.

◆ 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<>"}})   
)

References StopAtAnchorBoundary.

◆ 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"}})   
)

References CrossBoundary.

◆ 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<>"}})   
)

References StopAtAnchorBoundary.

◆ 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"}})   
)

References CrossBoundary.

◆ 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<>"}})   
)

References StopAtAnchorBoundary.

◆ 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"}})   
)

References CrossBoundary.

◆ 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<>"}})   
)

References StopAtAnchorBoundary.

◆ 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"}})   
)

References CrossBoundary.

◆ 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<>"}})   
)

References StopAtAnchorBoundary.

◆ 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"}})   
)

References CrossBoundary.

◆ 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<>"}})   
)

References StopAtAnchorBoundary.

◆ 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"}})   
)

References CrossBoundary.

◆ 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"}})   
)

References StopAtAnchorBoundary.

◆ 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"}})   
)

References CrossBoundary.

◆ 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"}})   
)

References StopAtAnchorBoundary.

◆ 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"}})   
)

References CrossBoundary.

◆ 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"}})   
)

References StopAtAnchorBoundary.

◆ 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"}})   
)

References CrossBoundary.

◆ 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"}})   
)

References StopAtAnchorBoundary.

◆ 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"}})   
)

References CrossBoundary.

◆ 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"}})   
)

References StopAtAnchorBoundary.

◆ 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"}})   
)

References CrossBoundary.

◆ 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"}})   
)

References StopAtAnchorBoundary.

◆ 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}

References ax::mojom::kAlert, and ax::mojom::kAlertDialog.

Referenced by ui::AXEventGenerator::OnAtomicUpdateFinished(), and ui::AXEventGenerator::OnStringAttributeChanged().

◆ 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}

References ax::mojom::kButton, ax::mojom::kPopUpButton, and ax::mojom::kToggleButton.

Referenced by ui::AXNodeData::IsButtonPressed(), ui::AXNodeData::IsMenuButton(), TEST(), and TEST().

◆ IsCellOrTableHeader()

◆ 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}

References ax::mojom::kButton, ax::mojom::kCheckBox, ax::mojom::kColorWell, ax::mojom::kComboBoxMenuButton, ax::mojom::kDate, ax::mojom::kDateTime, ax::mojom::kDisclosureTriangle, ax::mojom::kDocBackLink, ax::mojom::kDocBiblioRef, ax::mojom::kDocGlossRef, ax::mojom::kDocNoteRef, ax::mojom::kImeCandidate, ax::mojom::kInputTime, ax::mojom::kLink, ax::mojom::kListBox, ax::mojom::kListBoxOption, ax::mojom::kMenuItem, ax::mojom::kMenuItemCheckBox, ax::mojom::kMenuItemRadio, ax::mojom::kMenuListOption, ax::mojom::kPdfActionableHighlight, ax::mojom::kPopUpButton, ax::mojom::kPortal, ax::mojom::kRadioButton, ax::mojom::kSearchBox, ax::mojom::kSpinButton, ax::mojom::kSwitch, ax::mojom::kTab, ax::mojom::kTextField, ax::mojom::kTextFieldWithComboBox, and ax::mojom::kToggleButton.

Referenced by ui::AXNodeData::IsClickable(), and ui::AXNodeData::~AXNodeData().

◆ IsContainerWithSelectableChildren()

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

Definition at line 123 of file ax_role_properties.cc.

References ax::mojom::kComboBoxGrouping, ax::mojom::kComboBoxMenuButton, ax::mojom::kGrid, ax::mojom::kListBox, ax::mojom::kListGrid, ax::mojom::kMenu, ax::mojom::kMenuBar, ax::mojom::kMenuListPopup, ax::mojom::kRadioGroup, ax::mojom::kTabList, ax::mojom::kToolbar, ax::mojom::kTree, and ax::mojom::kTreeGrid.

Referenced by ui::AXPlatformNodeBase::GetMaxSelectableItems(), ui::AXPlatformNodeBase::GetSelectionContainer(), and ui::AXEventGenerator::OnBoolAttributeChanged().

◆ IsControl()

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

Definition at line 144 of file ax_role_properties.cc.

References ax::mojom::kButton, ax::mojom::kCheckBox, ax::mojom::kColorWell, ax::mojom::kComboBoxMenuButton, ax::mojom::kDisclosureTriangle, ax::mojom::kListBox, ax::mojom::kListGrid, ax::mojom::kMenu, ax::mojom::kMenuBar, ax::mojom::kMenuItem, ax::mojom::kMenuItemCheckBox, ax::mojom::kMenuItemRadio, ax::mojom::kMenuListOption, ax::mojom::kMenuListPopup, ax::mojom::kPdfActionableHighlight, ax::mojom::kPopUpButton, ax::mojom::kRadioButton, ax::mojom::kScrollBar, ax::mojom::kSearchBox, ax::mojom::kSlider, ax::mojom::kSpinButton, ax::mojom::kSwitch, ax::mojom::kTab, ax::mojom::kTextField, ax::mojom::kTextFieldWithComboBox, ax::mojom::kToggleButton, and ax::mojom::kTree.

Referenced by IsControlOnAndroid(), and IsFormatBoundary().

◆ IsControlOnAndroid()

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

◆ 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}

References ax::mojom::kAlertDialog, and ax::mojom::kDialog.

◆ IsDocument()

◆ 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}

References ax::mojom::kForm.

◆ 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)

References IsControl(), IsHeading(), and IsImageOrVideo().

◆ 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}

References ax::mojom::kDocSubtitle, and ax::mojom::kHeading.

Referenced by IsFormatBoundary().

◆ 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}

References ax::mojom::kColumnHeader, ax::mojom::kDocSubtitle, ax::mojom::kHeading, and ax::mojom::kRowHeader.

◆ 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}

References ax::mojom::kIframe, and ax::mojom::kIframePresentational.

Referenced by ui::AXPosition< AXPositionType, AXNodeType >::IsEmptyObjectReplacedByCharacter().

◆ IsImage()

◆ 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}

References IsImage(), and ax::mojom::kVideo.

Referenced by IsFormatBoundary().

◆ IsItemLike()

◆ IsLandmark()

◆ 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}

References ax::mojom::kDocBackLink, ax::mojom::kDocBiblioRef, ax::mojom::kDocGlossRef, ax::mojom::kDocNoteRef, and ax::mojom::kLink.

Referenced by IsValuePatternSupported().

◆ IsList()

◆ IsListItem()

◆ 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}

References ax::mojom::kMenuItem, ax::mojom::kMenuItemCheckBox, and ax::mojom::kMenuItemRadio.

Referenced by ui::AXPlatformNodeMac::NotifyAccessibilityEvent().

◆ IsMenuRelated()

◆ IsNameExposedInAXValueForRole()

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

Definition at line 1131 of file ax_platform_node_mac.mm.

1131 {
1132 switch (role) {
1138 return true;
1139 default:
1140 return false;
1141 }
1142}

References ax::mojom::kListBoxOption, ax::mojom::kListMarker, ax::mojom::kMenuListOption, ax::mojom::kStaticText, and ax::mojom::kTitleBar.

◆ 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

References BASE_UNREACHABLE, ax::mojom::kActivedescendantId, ax::mojom::kAriaCellColumnIndex, ax::mojom::kAriaCellColumnSpan, ax::mojom::kAriaCellRowIndex, ax::mojom::kAriaCellRowSpan, ax::mojom::kAriaColumnCount, ax::mojom::kAriaCurrentState, ax::mojom::kAriaRowCount, ax::mojom::kBackgroundColor, ax::mojom::kCheckedState, ax::mojom::kColor, ax::mojom::kColorValue, ax::mojom::kDefaultActionVerb, ax::mojom::kDescriptionFrom, ax::mojom::kDOMNodeId, ax::mojom::kDropeffect, ax::mojom::kErrormessageId, ax::mojom::kHasPopup, ax::mojom::kHierarchicalLevel, ax::mojom::kImageAnnotationStatus, ax::mojom::kInPageLinkTargetId, ax::mojom::kInvalidState, ax::mojom::kListStyle, ax::mojom::kMemberOfId, ax::mojom::kNameFrom, ax::mojom::kNextFocusId, ax::mojom::kNextOnLineId, ax::mojom::kNone, ax::mojom::kPopupForId, ax::mojom::kPosInSet, ax::mojom::kPreviousFocusId, ax::mojom::kPreviousOnLineId, ax::mojom::kRestriction, ax::mojom::kScrollX, ax::mojom::kScrollXMax, ax::mojom::kScrollXMin, ax::mojom::kScrollY, ax::mojom::kScrollYMax, ax::mojom::kScrollYMin, ax::mojom::kSetSize, ax::mojom::kSortDirection, ax::mojom::kTableCellColumnIndex, ax::mojom::kTableCellColumnSpan, ax::mojom::kTableCellRowIndex, ax::mojom::kTableCellRowSpan, ax::mojom::kTableColumnCount, ax::mojom::kTableColumnHeaderId, ax::mojom::kTableColumnIndex, ax::mojom::kTableHeaderId, ax::mojom::kTableRowCount, ax::mojom::kTableRowHeaderId, ax::mojom::kTableRowIndex, ax::mojom::kTextAlign, ax::mojom::kTextDirection, ax::mojom::kTextOverlineStyle, ax::mojom::kTextPosition, ax::mojom::kTextSelEnd, ax::mojom::kTextSelStart, ax::mojom::kTextStrikethroughStyle, ax::mojom::kTextStyle, and ax::mojom::kTextUnderlineStyle.

Referenced by ui::TestAXNodeWrapper::GetReverseRelations(), ui::AXTree::GetReverseRelations(), and ui::AXPlatformNodeDelegateBase::GetTargetNodeForRelation().

◆ 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}

References BASE_UNREACHABLE, ax::mojom::kCachedLineStarts, ax::mojom::kCharacterOffsets, ax::mojom::kControlsIds, ax::mojom::kCustomActionIds, ax::mojom::kDescribedbyIds, ax::mojom::kDetailsIds, ax::mojom::kFlowtoIds, ax::mojom::kIndirectChildIds, ax::mojom::kLabelledbyIds, ax::mojom::kMarkerEnds, ax::mojom::kMarkerStarts, ax::mojom::kMarkerTypes, ax::mojom::kNone, ax::mojom::kRadioGroupIds, ax::mojom::kWordEnds, and ax::mojom::kWordStarts.

Referenced by ui::TestAXNodeWrapper::GetReverseRelations(), ui::AXTree::GetReverseRelations(), and ui::AXPlatformNodeDelegateBase::GetTargetNodesForRelation().

◆ 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}

References ax::mojom::kNone, and ax::mojom::kPresentational.

◆ 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}

References ax::mojom::kMenuItemRadio, and ax::mojom::kRadioButton.

◆ 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}

References ax::mojom::kMeter, ax::mojom::kProgressIndicator, ax::mojom::kScrollBar, ax::mojom::kSlider, ax::mojom::kSpinButton, and ax::mojom::kSplitter.

Referenced by ui::TestAXNodeWrapper::AccessibilityPerformAction(), ui::AXPlatformNodeBase::ComputeAttributes(), ui::AXPlatformNodeBase::GetValue(), ui::AXNodeData::IsRangeValueSupported(), and ui::AXNodeData::~AXNodeData().

◆ 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}

References ax::mojom::kCell, ax::mojom::kCheckBox, ax::mojom::kColorWell, ax::mojom::kColumnHeader, ax::mojom::kComboBoxGrouping, ax::mojom::kComboBoxMenuButton, ax::mojom::kDate, ax::mojom::kDateTime, ax::mojom::kGrid, ax::mojom::kInputTime, ax::mojom::kListBox, ax::mojom::kMenuItemCheckBox, ax::mojom::kMenuItemRadio, ax::mojom::kMenuListPopup, ax::mojom::kPopUpButton, ax::mojom::kRadioButton, ax::mojom::kRadioGroup, ax::mojom::kRowHeader, ax::mojom::kSearchBox, ax::mojom::kSlider, ax::mojom::kSpinButton, ax::mojom::kSwitch, ax::mojom::kTextField, ax::mojom::kTextFieldWithComboBox, ax::mojom::kToggleButton, and ax::mojom::kTreeGrid.

Referenced by ui::AXNodeData::IsReadOnlyOrDisabled(), and IsValuePatternSupported().

◆ 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}

References ax::mojom::kGrid, ax::mojom::kLayoutTable, ax::mojom::kListGrid, ax::mojom::kTable, ax::mojom::kTree, and ax::mojom::kTreeGrid.

Referenced by ui::AXEventGenerator::OnStateChanged().

◆ 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)

References IsLandmark(), IsSelect(), ax::mojom::kAlert, ax::mojom::kAlertDialog, ax::mojom::kCell, ax::mojom::kColumnHeader, ax::mojom::kDefinition, ax::mojom::kDirectory, ax::mojom::kFeed, ax::mojom::kFigure, ax::mojom::kGrid, ax::mojom::kGroup, ax::mojom::kImage, ax::mojom::kList, ax::mojom::kListItem, ax::mojom::kLog, ax::mojom::kMarquee, ax::mojom::kMath, ax::mojom::kNote, ax::mojom::kProgressIndicator, ax::mojom::kRow, ax::mojom::kRowHeader, ax::mojom::kSection, ax::mojom::kStatus, ax::mojom::kTable, ax::mojom::kTabPanel, ax::mojom::kTerm, ax::mojom::kTimer, ax::mojom::kToolbar, ax::mojom::kTooltip, and ax::mojom::kTreeItem.

Referenced by IsStructure().

◆ 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}

References ax::mojom::kColumnHeader, ax::mojom::kHeading, ax::mojom::kRowHeader, and ax::mojom::kTab.

Referenced by IsStructure().

◆ 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}

References ax::mojom::kComboBoxGrouping, ax::mojom::kListBox, ax::mojom::kMenu, ax::mojom::kMenuBar, ax::mojom::kRadioGroup, ax::mojom::kTree, and ax::mojom::kTreeGrid.

Referenced by IsSection().

◆ IsSetLike()

◆ 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}

References ax::mojom::kDescriptionList, and ax::mojom::kList.

◆ 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)

References IsSection(), IsSectionhead(), ax::mojom::kApplication, ax::mojom::kArticle, ax::mojom::kDocAbstract, ax::mojom::kDocAcknowledgments, ax::mojom::kDocAfterword, ax::mojom::kDocAppendix, ax::mojom::kDocBiblioEntry, ax::mojom::kDocBibliography, ax::mojom::kDocChapter, ax::mojom::kDocColophon, ax::mojom::kDocConclusion, ax::mojom::kDocCover, ax::mojom::kDocCredit, ax::mojom::kDocCredits, ax::mojom::kDocDedication, ax::mojom::kDocEndnote, ax::mojom::kDocEndnotes, ax::mojom::kDocEpigraph, ax::mojom::kDocEpilogue, ax::mojom::kDocErrata, ax::mojom::kDocExample, ax::mojom::kDocFootnote, ax::mojom::kDocForeword, ax::mojom::kDocGlossary, ax::mojom::kDocIndex, ax::mojom::kDocIntroduction, ax::mojom::kDocNotice, ax::mojom::kDocPageBreak, ax::mojom::kDocPageList, ax::mojom::kDocPart, ax::mojom::kDocPreface, ax::mojom::kDocPrologue, ax::mojom::kDocQna, ax::mojom::kDocSubtitle, ax::mojom::kDocTip, ax::mojom::kDocToc, ax::mojom::kDocument, ax::mojom::kPresentational, ax::mojom::kRowGroup, and ax::mojom::kSplitter.

◆ 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}

References ax::mojom::kColumn.

◆ 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}

References ax::mojom::kColumnHeader, and ax::mojom::kRowHeader.

Referenced by ui::AXPlatformNodeBase::ComputeAttributes(), and ui::AXEventGenerator::OnIntAttributeChanged().

◆ IsTableLike()

◆ 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}

References ax::mojom::kLayoutTableRow, and ax::mojom::kRow.

Referenced by ui::AXPlatformNodeBase::ComputeAttributes(), ui::AXNode::IsTableRow(), and ui::AXPlatformNodeDelegateBase::IsTableRow().

◆ IsText()

◆ 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

References ui::AXPlatformNodeDelegate::GetData(), ui::AXPlatformNodeDelegate::IsCellOrHeaderOfARIAGrid(), IsLink(), ui::AXNodeData::IsRangeValueSupported(), IsReadOnlySupported(), ax::mojom::kColorWell, and ui::AXNodeData::role.

◆ kAXModeComplete()

Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().

◆ kAXModeWebContentsOnly()

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

◆ operator!=() [1/2]

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

References ui::AXPosition< AXPositionType, AXNodeType >::CompareTo().

◆ operator!=() [2/2]

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}

References ui::AXPosition< AXPositionType, AXNodeType >::CompareTo().

◆ 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}
const char * ToString(ax::mojom::Event event)

References ToString().

◆ 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}

◆ 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}

◆ 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

References ui::AXNode::data(), and ui::AXNodeData::ToString().

◆ 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

References ui::AXPosition< AXPositionType, AXNodeType >::ToString().

◆ 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

References ui::AXRange< AXPositionType >::ToString().

◆ 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}
std::string ToString() const

References ui::AXRelativeBounds::ToString().

◆ 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}
int32_t value

References 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}

References ui::AXPosition< AXPositionType, AXNodeType >::CompareTo().

◆ 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}
ax::mojom::Command command
ax::mojom::TextBoundary text_boundary
ax::mojom::MoveDirection move_direction

◆ 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}

References ui::AXPosition< AXPositionType, AXNodeType >::CompareTo().

◆ 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
AXNode::AXID sel_anchor_object_id
AXTreeID focused_tree_id
ax::mojom::TextAffinity sel_focus_affinity
AXNode::AXID sel_focus_object_id
std::string mimetype
std::string doctype
AXNode::AXID focus_id
int32_t sel_focus_offset
ax::mojom::TextAffinity sel_anchor_affinity
AXTreeID parent_tree_id
std::string title
AXTreeID tree_id
float loading_progress
int32_t sel_anchor_offset

References ui::AXTreeData::doctype, ui::AXTreeData::focus_id, ui::AXTreeData::focused_tree_id, ui::AXTreeData::loaded, ui::AXTreeData::loading_progress, ui::AXTreeData::mimetype, ui::AXTreeData::parent_tree_id, ui::AXTreeData::sel_anchor_affinity, ui::AXTreeData::sel_anchor_object_id, ui::AXTreeData::sel_anchor_offset, ui::AXTreeData::sel_focus_affinity, ui::AXTreeData::sel_focus_object_id, ui::AXTreeData::sel_focus_offset, ui::AXTreeData::title, ui::AXTreeData::tree_id, and ui::AXTreeData::url.

◆ 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}

References ui::AXPosition< AXPositionType, AXNodeType >::CompareTo().

◆ 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}

References ui::AXPosition< AXPositionType, AXNodeType >::CompareTo().

◆ 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

References action, ax::mojom::kAnnotatePageImages, ax::mojom::kBlur, ax::mojom::kClearAccessibilityFocus, ax::mojom::kCollapse, ax::mojom::kCustomAction, ax::mojom::kDecrement, ax::mojom::kDoDefault, ax::mojom::kExpand, ax::mojom::kFocus, ax::mojom::kGetImageData, ax::mojom::kGetTextLocation, ax::mojom::kHideTooltip, ax::mojom::kHitTest, ax::mojom::kIncrement, ax::mojom::kInternalInvalidateTree, ax::mojom::kLoadInlineTextBoxes, ax::mojom::kNone, ax::mojom::kReplaceSelectedText, ax::mojom::kScrollBackward, ax::mojom::kScrollDown, ax::mojom::kScrollForward, ax::mojom::kScrollLeft, ax::mojom::kScrollRight, ax::mojom::kScrollToMakeVisible, ax::mojom::kScrollToPoint, ax::mojom::kScrollUp, ax::mojom::kSetAccessibilityFocus, ax::mojom::kSetScrollOffset, ax::mojom::kSetSelection, ax::mojom::kSetSequentialFocusNavigationStartingPoint, ax::mojom::kSetValue, ax::mojom::kShowContextMenu, ax::mojom::kShowTooltip, and ax::mojom::kSignalEndOfTest.

Referenced by TEST().

◆ 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}

References ax::mojom::kNone, ax::mojom::kRequestImages, and ax::mojom::kRequestInlineTextBoxes.

Referenced by TEST().

◆ ParseAriaCurrentState()

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

Definition at line 2442 of file ax_enum_util.cc.

2443 {
2444 if (0 == strcmp(aria_current_state, "none"))
2446 if (0 == strcmp(aria_current_state, "false"))
2448 if (0 == strcmp(aria_current_state, "true"))
2450 if (0 == strcmp(aria_current_state, "page"))
2452 if (0 == strcmp(aria_current_state, "step"))
2454 if (0 == strcmp(aria_current_state, "location"))
2456 if (0 == strcmp(aria_current_state, "unclippedLocation"))
2458 if (0 == strcmp(aria_current_state, "date"))
2460 if (0 == strcmp(aria_current_state, "time"))
2463}

References ax::mojom::kDate, ax::mojom::kFalse, ax::mojom::kLocation, ax::mojom::kNone, ax::mojom::kPage, ax::mojom::kStep, ax::mojom::kTime, ax::mojom::kTrue, and ax::mojom::kUnclippedLocation.

Referenced by TEST().

◆ ParseBoolAttribute()

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

Definition at line 1876 of file ax_enum_util.cc.

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

References ax::mojom::kBusy, ax::mojom::kCanvasHasFallback, ax::mojom::kClickable, ax::mojom::kClipsChildren, ax::mojom::kContainerLiveAtomic, ax::mojom::kContainerLiveBusy, ax::mojom::kEditableRoot, ax::mojom::kGrabbed, ax::mojom::kHasAriaAttribute, ax::mojom::kIsLineBreakingObject, ax::mojom::kIsPageBreakingObject, ax::mojom::kLiveAtomic, ax::mojom::kModal, ax::mojom::kNone, ax::mojom::kNotUserSelectableStyle, ax::mojom::kScrollable, ax::mojom::kSelected, ax::mojom::kSelectedFromFocus, ax::mojom::kSupportsTextLocation, and ax::mojom::kUpdateLocationOnly.

Referenced by TEST().

◆ ParseCheckedState()

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

Definition at line 2568 of file ax_enum_util.cc.

2568 {
2569 if (0 == strcmp(checked_state, "none"))
2571 if (0 == strcmp(checked_state, "false"))
2573 if (0 == strcmp(checked_state, "true"))
2575 if (0 == strcmp(checked_state, "mixed"))
2578}

References ax::mojom::kFalse, ax::mojom::kMixed, ax::mojom::kNone, and ax::mojom::kTrue.

Referenced by TEST().

◆ ParseCommand()

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

Definition at line 2142 of file ax_enum_util.cc.

2142 {
2143 if (0 == strcmp(command, "clearSelection"))
2145 if (0 == strcmp(command, "cut"))
2147 if (0 == strcmp(command, "delete"))
2149 if (0 == strcmp(command, "dictate"))
2151 if (0 == strcmp(command, "extendSelection"))
2153 if (0 == strcmp(command, "format"))
2155 if (0 == strcmp(command, "insert"))
2157 if (0 == strcmp(command, "marker"))
2159 if (0 == strcmp(command, "moveSelection"))
2161 if (0 == strcmp(command, "paste"))
2163 if (0 == strcmp(command, "replace"))
2165 if (0 == strcmp(command, "setSelection"))
2167 if (0 == strcmp(command, "type"))
2169
2170 // Return the default command.
2172}

References ax::mojom::kClearSelection, ax::mojom::kCut, ax::mojom::kDelete, ax::mojom::kDictate, ax::mojom::kExtendSelection, ax::mojom::kFormat, ax::mojom::kInsert, ax::mojom::kMarker, ax::mojom::kMoveSelection, ax::mojom::kPaste, ax::mojom::kReplace, ax::mojom::kSetSelection, and ax::mojom::kType.

Referenced by TEST().

◆ 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}

References ax::mojom::kActivate, ax::mojom::kCheck, ax::mojom::kClick, ax::mojom::kClickAncestor, ax::mojom::kJump, ax::mojom::kNone, ax::mojom::kOpen, ax::mojom::kPress, ax::mojom::kSelect, and ax::mojom::kUncheck.

Referenced by TEST().

◆ ParseDescriptionFrom()

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

Definition at line 2681 of file ax_enum_util.cc.

2681 {
2682 if (0 == strcmp(description_from, "none"))
2684 if (0 == strcmp(description_from, "uninitialized"))
2686 if (0 == strcmp(description_from, "attribute"))
2688 if (0 == strcmp(description_from, "contents"))
2690 if (0 == strcmp(description_from, "relatedElement"))
2692 if (0 == strcmp(description_from, "title"))
2695}

References ax::mojom::kAttribute, ax::mojom::kContents, ax::mojom::kNone, ax::mojom::kRelatedElement, ax::mojom::kTitle, and ax::mojom::kUninitialized.

Referenced by TEST().

◆ ParseDropeffect()

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

Definition at line 2949 of file ax_enum_util.cc.

2949 {
2950 if (0 == strcmp(dropeffect, "copy"))
2952 if (0 == strcmp(dropeffect, "execute"))
2954 if (0 == strcmp(dropeffect, "link"))
2956 if (0 == strcmp(dropeffect, "move"))
2958 if (0 == strcmp(dropeffect, "popup"))
2961}

References ax::mojom::kCopy, ax::mojom::kExecute, ax::mojom::kLink, ax::mojom::kMove, ax::mojom::kNone, and ax::mojom::kPopup.

Referenced by TEST().

◆ 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}

References ax::mojom::kActiveDescendantChanged, ax::mojom::kAlert, ax::mojom::kAriaAttributeChanged, ax::mojom::kAutocorrectionOccured, ax::mojom::kBlur, ax::mojom::kCheckedStateChanged, ax::mojom::kChildrenChanged, ax::mojom::kClicked, ax::mojom::kControlsChanged, ax::mojom::kDocumentSelectionChanged, ax::mojom::kDocumentTitleChanged, ax::mojom::kEndOfTest, ax::mojom::kExpandedChanged, ax::mojom::kFocus, ax::mojom::kFocusAfterMenuClose, ax::mojom::kFocusContext, ax::mojom::kHide, ax::mojom::kHitTestResult, ax::mojom::kHover, ax::mojom::kImageFrameUpdated, ax::mojom::kInvalidStatusChanged, ax::mojom::kLayoutComplete, ax::mojom::kLiveRegionChanged, ax::mojom::kLiveRegionCreated, ax::mojom::kLoadComplete, ax::mojom::kLoadStart, ax::mojom::kLocationChanged, ax::mojom::kMediaStartedPlaying, ax::mojom::kMediaStoppedPlaying, ax::mojom::kMenuEnd, ax::mojom::kMenuListItemSelected, ax::mojom::kMenuListValueChanged, ax::mojom::kMenuPopupEnd, ax::mojom::kMenuPopupStart, ax::mojom::kMenuStart, ax::mojom::kMouseCanceled, ax::mojom::kMouseDragged, ax::mojom::kMouseMoved, ax::mojom::kMousePressed, ax::mojom::kMouseReleased, ax::mojom::kNone, ax::mojom::kRowCollapsed, ax::mojom::kRowCountChanged, ax::mojom::kRowExpanded, ax::mojom::kScrolledToAnchor, ax::mojom::kScrollPositionChanged, ax::mojom::kSelectedChildrenChanged, ax::mojom::kSelection, ax::mojom::kSelectionAdd, ax::mojom::kSelectionRemove, ax::mojom::kShow, ax::mojom::kStateChanged, ax::mojom::kTextChanged, ax::mojom::kTextSelectionChanged, ax::mojom::kTooltipClosed, ax::mojom::kTooltipOpened, ax::mojom::kTreeChanged, ax::mojom::kValueChanged, ax::mojom::kWindowActivated, ax::mojom::kWindowDeactivated, and ax::mojom::kWindowVisibilityChanged.

Referenced by TEST().

◆ ParseEventFrom()

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

Definition at line 2712 of file ax_enum_util.cc.

2712 {
2713 if (0 == strcmp(event_from, "none"))
2715 if (0 == strcmp(event_from, "user"))
2717 if (0 == strcmp(event_from, "page"))
2719 if (0 == strcmp(event_from, "action"))
2722}

References ax::mojom::kAction, ax::mojom::kNone, ax::mojom::kPage, and ax::mojom::kUser.

Referenced by TEST().

◆ ParseFloatAttribute()

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

Definition at line 1809 of file ax_enum_util.cc.

1809 {
1810 if (0 == strcmp(float_attribute, "none"))
1812 if (0 == strcmp(float_attribute, "valueForRange"))
1814 if (0 == strcmp(float_attribute, "minValueForRange"))
1816 if (0 == strcmp(float_attribute, "maxValueForRange"))
1818 if (0 == strcmp(float_attribute, "stepValueForRange"))
1820 if (0 == strcmp(float_attribute, "fontSize"))
1822 if (0 == strcmp(float_attribute, "fontWeight"))
1824 if (0 == strcmp(float_attribute, "textIndent"))
1827}

References ax::mojom::kFontSize, ax::mojom::kFontWeight, ax::mojom::kMaxValueForRange, ax::mojom::kMinValueForRange, ax::mojom::kNone, ax::mojom::kStepValueForRange, ax::mojom::kTextIndent, and ax::mojom::kValueForRange.

Referenced by TEST().

◆ ParseGesture()

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

Definition at line 2775 of file ax_enum_util.cc.

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

References ax::mojom::kClick, ax::mojom::kNone, ax::mojom::kSwipeDown1, ax::mojom::kSwipeDown2, ax::mojom::kSwipeDown3, ax::mojom::kSwipeDown4, ax::mojom::kSwipeLeft1, ax::mojom::kSwipeLeft2, ax::mojom::kSwipeLeft3, ax::mojom::kSwipeLeft4, ax::mojom::kSwipeRight1, ax::mojom::kSwipeRight2, ax::mojom::kSwipeRight3, ax::mojom::kSwipeRight4, ax::mojom::kSwipeUp1, ax::mojom::kSwipeUp2, ax::mojom::kSwipeUp3, ax::mojom::kSwipeUp4, ax::mojom::kTap2, ax::mojom::kTap3, ax::mojom::kTap4, and ax::mojom::kTouchExplore.

Referenced by TEST().

◆ ParseHasPopup()

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

Definition at line 2486 of file ax_enum_util.cc.

2486 {
2487 if (0 == strcmp(has_popup, "true"))
2489 if (0 == strcmp(has_popup, "menu"))
2491 if (0 == strcmp(has_popup, "listbox"))
2493 if (0 == strcmp(has_popup, "tree"))
2495 if (0 == strcmp(has_popup, "grid"))
2497 if (0 == strcmp(has_popup, "dialog"))
2499
2501}

References ax::mojom::kDialog, ax::mojom::kFalse, ax::mojom::kGrid, ax::mojom::kListbox, ax::mojom::kMenu, ax::mojom::kTree, and ax::mojom::kTrue.

Referenced by TEST().

◆ ParseImageAnnotationStatus()

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

Definition at line 2904 of file ax_enum_util.cc.

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

References ax::mojom::kAnnotationAdult, ax::mojom::kAnnotationEmpty, ax::mojom::kAnnotationPending, ax::mojom::kAnnotationProcessFailed, ax::mojom::kAnnotationSucceeded, ax::mojom::kEligibleForAnnotation, ax::mojom::kIneligibleForAnnotation, ax::mojom::kNone, ax::mojom::kSilentlyEligibleForAnnotation, and ax::mojom::kWillNotAnnotateDueToScheme.

Referenced by TEST().

◆ ParseIntAttribute()

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

Definition at line 1660 of file ax_enum_util.cc.

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

References ax::mojom::kActivedescendantId, ax::mojom::kAriaCellColumnIndex, ax::mojom::kAriaCellColumnSpan, ax::mojom::kAriaCellRowIndex, ax::mojom::kAriaCellRowSpan, ax::mojom::kAriaColumnCount, ax::mojom::kAriaCurrentState, ax::mojom::kAriaRowCount, ax::mojom::kBackgroundColor, ax::mojom::kCheckedState, ax::mojom::kColor, ax::mojom::kColorValue, ax::mojom::kDefaultActionVerb, ax::mojom::kDescriptionFrom, ax::mojom::kDOMNodeId, ax::mojom::kDropeffect, ax::mojom::kErrormessageId, ax::mojom::kHasPopup, ax::mojom::kHierarchicalLevel, ax::mojom::kImageAnnotationStatus, ax::mojom::kInPageLinkTargetId, ax::mojom::kInvalidState, ax::mojom::kListStyle, ax::mojom::kMemberOfId, ax::mojom::kNameFrom, ax::mojom::kNextFocusId, ax::mojom::kNextOnLineId, ax::mojom::kNone, ax::mojom::kPopupForId, ax::mojom::kPosInSet, ax::mojom::kPreviousFocusId, ax::mojom::kPreviousOnLineId, ax::mojom::kRestriction, ax::mojom::kScrollX, ax::mojom::kScrollXMax, ax::mojom::kScrollXMin, ax::mojom::kScrollY, ax::mojom::kScrollYMax, ax::mojom::kScrollYMin, ax::mojom::kSetSize, ax::mojom::kSortDirection, ax::mojom::kTableCellColumnIndex, ax::mojom::kTableCellColumnSpan, ax::mojom::kTableCellRowIndex, ax::mojom::kTableCellRowSpan, ax::mojom::kTableColumnCount, ax::mojom::kTableColumnHeaderId, ax::mojom::kTableColumnIndex, ax::mojom::kTableHeaderId, ax::mojom::kTableRowCount, ax::mojom::kTableRowHeaderId, ax::mojom::kTableRowIndex, ax::mojom::kTextAlign, ax::mojom::kTextDirection, ax::mojom::kTextOverlineStyle, ax::mojom::kTextPosition, ax::mojom::kTextSelEnd, ax::mojom::kTextSelStart, ax::mojom::kTextStrikethroughStyle, ax::mojom::kTextStyle, and ax::mojom::kTextUnderlineStyle.

Referenced by TEST().

◆ ParseIntListAttribute()

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

Definition at line 1959 of file ax_enum_util.cc.

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

References ax::mojom::kCachedLineStarts, ax::mojom::kCharacterOffsets, ax::mojom::kControlsIds, ax::mojom::kCustomActionIds, ax::mojom::kDescribedbyIds, ax::mojom::kDetailsIds, ax::mojom::kFlowtoIds, ax::mojom::kIndirectChildIds, ax::mojom::kLabelledbyIds, ax::mojom::kMarkerEnds, ax::mojom::kMarkerStarts, ax::mojom::kMarkerTypes, ax::mojom::kNone, ax::mojom::kRadioGroupIds, ax::mojom::kWordEnds, and ax::mojom::kWordStarts.

Referenced by TEST().

◆ ParseInvalidState()

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

Definition at line 2518 of file ax_enum_util.cc.

2518 {
2519 if (0 == strcmp(invalid_state, "none"))
2521 if (0 == strcmp(invalid_state, "false"))
2523 if (0 == strcmp(invalid_state, "true"))
2525 if (0 == strcmp(invalid_state, "other"))
2528}

References ax::mojom::kFalse, ax::mojom::kNone, ax::mojom::kOther, and ax::mojom::kTrue.

Referenced by TEST().

◆ ParseListStyle()

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

Definition at line 2037 of file ax_enum_util.cc.

2037 {
2038 if (0 == strcmp(list_style, "none"))
2040 if (0 == strcmp(list_style, "circle"))
2042 if (0 == strcmp(list_style, "disc"))
2044 if (0 == strcmp(list_style, "image"))
2046 if (0 == strcmp(list_style, "numeric"))
2048 if (0 == strcmp(list_style, "other"))
2050 if (0 == strcmp(list_style, "square"))
2053}

References ax::mojom::kCircle, ax::mojom::kDisc, ax::mojom::kImage, ax::mojom::kNone, ax::mojom::kNumeric, ax::mojom::kOther, and ax::mojom::kSquare.

Referenced by TEST().

◆ ParseMarkerType()

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

Definition at line 2074 of file ax_enum_util.cc.

2074 {
2075 if (0 == strcmp(marker_type, "none"))
2077 if (0 == strcmp(marker_type, "spelling"))
2079 if (0 == strcmp(marker_type, "grammar"))
2081 if (0 == strcmp(marker_type, "textMatch"))
2083 if (0 == strcmp(marker_type, "activeSuggestion"))
2085 if (0 == strcmp(marker_type, "suggestion"))
2088}

References ax::mojom::kActiveSuggestion, ax::mojom::kGrammar, ax::mojom::kNone, ax::mojom::kSpelling, ax::mojom::kSuggestion, and ax::mojom::kTextMatch.

Referenced by TEST().

◆ ParseMoveDirection()

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

Definition at line 2101 of file ax_enum_util.cc.

2101 {
2102 if (0 == strcmp(move_direction, "forward"))
2104 if (0 == strcmp(move_direction, "backward"))
2107}

References ax::mojom::kBackward, and ax::mojom::kForward.

Referenced by TEST().

◆ 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}

References ax::mojom::kNodeChanged, ax::mojom::kNodeCreated, ax::mojom::kNodeRemoved, ax::mojom::kNone, and ax::mojom::kSubtreeCreated.

Referenced by TEST().

◆ ParseNameFrom()

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

Definition at line 2638 of file ax_enum_util.cc.

2638 {
2639 if (0 == strcmp(name_from, "none"))
2641 if (0 == strcmp(name_from, "uninitialized"))
2643 if (0 == strcmp(name_from, "attribute"))
2645 if (0 == strcmp(name_from, "attributeExplicitlyEmpty"))
2647 if (0 == strcmp(name_from, "caption"))
2649 if (0 == strcmp(name_from, "contents"))
2651 if (0 == strcmp(name_from, "placeholder"))
2653 if (0 == strcmp(name_from, "relatedElement"))
2655 if (0 == strcmp(name_from, "title"))
2657 if (0 == strcmp(name_from, "value"))
2660}

References ax::mojom::kAttribute, ax::mojom::kAttributeExplicitlyEmpty, ax::mojom::kCaption, ax::mojom::kContents, ax::mojom::kNone, ax::mojom::kPlaceholder, ax::mojom::kRelatedElement, ax::mojom::kTitle, ax::mojom::kUninitialized, and ax::mojom::kValue.

Referenced by TEST().

◆ ParseRestriction()

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

Definition at line 2543 of file ax_enum_util.cc.

2543 {
2544 if (0 == strcmp(restriction, "none"))
2546 if (0 == strcmp(restriction, "readOnly"))
2548 if (0 == strcmp(restriction, "disabled"))
2551}

References ax::mojom::kDisabled, ax::mojom::kNone, and ax::mojom::kReadOnly.

Referenced by TEST().

◆ 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}

References ax::mojom::kAbbr, ax::mojom::kAlert, ax::mojom::kAlertDialog, ax::mojom::kAnchor, ax::mojom::kApplication, ax::mojom::kArticle, ax::mojom::kAudio, ax::mojom::kBanner, ax::mojom::kBlockquote, ax::mojom::kButton, ax::mojom::kCanvas, ax::mojom::kCaption, ax::mojom::kCaret, ax::mojom::kCell, ax::mojom::kCheckBox, ax::mojom::kClient, ax::mojom::kCode, ax::mojom::kColorWell, ax::mojom::kColumn, ax::mojom::kColumnHeader, ax::mojom::kComboBoxGrouping, ax::mojom::kComboBoxMenuButton, ax::mojom::kComment, ax::mojom::kComplementary, ax::mojom::kContentDeletion, ax::mojom::kContentInfo, ax::mojom::kContentInsertion, ax::mojom::kDate, ax::mojom::kDateTime, ax::mojom::kDefinition, ax::mojom::kDescriptionList, ax::mojom::kDescriptionListDetail, ax::mojom::kDescriptionListTerm, ax::mojom::kDesktop, ax::mojom::kDetails, ax::mojom::kDialog, ax::mojom::kDirectory, ax::mojom::kDisclosureTriangle, ax::mojom::kDocAbstract, ax::mojom::kDocAcknowledgments, ax::mojom::kDocAfterword, ax::mojom::kDocAppendix, ax::mojom::kDocBackLink, ax::mojom::kDocBiblioEntry, ax::mojom::kDocBibliography, ax::mojom::kDocBiblioRef, ax::mojom::kDocChapter, ax::mojom::kDocColophon, ax::mojom::kDocConclusion, ax::mojom::kDocCover, ax::mojom::kDocCredit, ax::mojom::kDocCredits, ax::mojom::kDocDedication, ax::mojom::kDocEndnote, ax::mojom::kDocEndnotes, ax::mojom::kDocEpigraph, ax::mojom::kDocEpilogue, ax::mojom::kDocErrata, ax::mojom::kDocExample, ax::mojom::kDocFootnote, ax::mojom::kDocForeword, ax::mojom::kDocGlossary, ax::mojom::kDocGlossRef, ax::mojom::kDocIndex, ax::mojom::kDocIntroduction, ax::mojom::kDocNoteRef, ax::mojom::kDocNotice, ax::mojom::kDocPageBreak, ax::mojom::kDocPageList, ax::mojom::kDocPart, ax::mojom::kDocPreface, ax::mojom::kDocPrologue, ax::mojom::kDocPullquote, ax::mojom::kDocQna, ax::mojom::kDocSubtitle, ax::mojom::kDocTip, ax::mojom::kDocToc, ax::mojom::kDocument, ax::mojom::kEmbeddedObject, ax::mojom::kEmphasis, ax::mojom::kFeed, ax::mojom::kFigcaption, ax::mojom::kFigure, ax::mojom::kFooter, ax::mojom::kFooterAsNonLandmark, ax::mojom::kForm, ax::mojom::kGenericContainer, ax::mojom::kGraphicsDocument, ax::mojom::kGraphicsObject, ax::mojom::kGraphicsSymbol, ax::mojom::kGrid, ax::mojom::kGroup, ax::mojom::kHeader, ax::mojom::kHeaderAsNonLandmark, ax::mojom::kHeading, ax::mojom::kIframe, ax::mojom::kIframePresentational, ax::mojom::kIgnored, ax::mojom::kImage, ax::mojom::kImageMap, ax::mojom::kImeCandidate, ax::mojom::kInlineTextBox, ax::mojom::kInputTime, ax::mojom::kKeyboard, ax::mojom::kLabelText, ax::mojom::kLayoutTable, ax::mojom::kLayoutTableCell, ax::mojom::kLayoutTableRow, ax::mojom::kLegend, ax::mojom::kLineBreak, ax::mojom::kLink, ax::mojom::kList, ax::mojom::kListBox, ax::mojom::kListBoxOption, ax::mojom::kListGrid, ax::mojom::kListItem, ax::mojom::kListMarker, ax::mojom::kLog, ax::mojom::kMain, ax::mojom::kMark, ax::mojom::kMarquee, ax::mojom::kMath, ax::mojom::kMenu, ax::mojom::kMenuBar, ax::mojom::kMenuItem, ax::mojom::kMenuItemCheckBox, ax::mojom::kMenuItemRadio, ax::mojom::kMenuListOption, ax::mojom::kMenuListPopup, ax::mojom::kMeter, ax::mojom::kNavigation, ax::mojom::kNone, ax::mojom::kNote, ax::mojom::kPane, ax::mojom::kParagraph, ax::mojom::kPdfActionableHighlight, ax::mojom::kPluginObject, ax::mojom::kPopUpButton, ax::mojom::kPortal, ax::mojom::kPre, ax::mojom::kPresentational, ax::mojom::kProgressIndicator, ax::mojom::kRadioButton, ax::mojom::kRadioGroup, ax::mojom::kRegion, ax::mojom::kRootWebArea, ax::mojom::kRow, ax::mojom::kRowGroup, ax::mojom::kRowHeader, ax::mojom::kRuby, ax::mojom::kRubyAnnotation, ax::mojom::kScrollBar, ax::mojom::kScrollView, ax::mojom::kSearch, ax::mojom::kSearchBox, ax::mojom::kSection, ax::mojom::kSlider, ax::mojom::kSliderThumb, ax::mojom::kSpinButton, ax::mojom::kSplitter, ax::mojom::kStaticText, ax::mojom::kStatus, ax::mojom::kStrong, ax::mojom::kSuggestion, ax::mojom::kSvgRoot, ax::mojom::kSwitch, ax::mojom::kTab, ax::mojom::kTable, ax::mojom::kTableHeaderContainer, ax::mojom::kTabList, ax::mojom::kTabPanel, ax::mojom::kTerm, ax::mojom::kTextField, ax::mojom::kTextFieldWithComboBox, ax::mojom::kTime, ax::mojom::kTimer, ax::mojom::kTitleBar, ax::mojom::kToggleButton, ax::mojom::kToolbar, ax::mojom::kTooltip, ax::mojom::kTree, ax::mojom::kTreeGrid, ax::mojom::kTreeItem, ax::mojom::kUnknown, ax::mojom::kVideo, ax::mojom::kWebArea, ax::mojom::kWebView, and ax::mojom::kWindow.

Referenced by TEST().

◆ 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}

References ax::mojom::kNone, ax::mojom::kScrollAlignmentBottom, ax::mojom::kScrollAlignmentCenter, ax::mojom::kScrollAlignmentClosestEdge, ax::mojom::kScrollAlignmentLeft, ax::mojom::kScrollAlignmentRight, and ax::mojom::kScrollAlignmentTop.

◆ ParseSortDirection()

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

Definition at line 2597 of file ax_enum_util.cc.

2597 {
2598 if (0 == strcmp(sort_direction, "none"))
2600 if (0 == strcmp(sort_direction, "unsorted"))
2602 if (0 == strcmp(sort_direction, "ascending"))
2604 if (0 == strcmp(sort_direction, "descending"))
2606 if (0 == strcmp(sort_direction, "other"))
2609}

References ax::mojom::kAscending, ax::mojom::kDescending, ax::mojom::kNone, ax::mojom::kOther, and ax::mojom::kUnsorted.

Referenced by TEST().

◆ 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}

References ax::mojom::kAutofillAvailable, ax::mojom::kCollapsed, ax::mojom::kDefault, ax::mojom::kEditable, ax::mojom::kExpanded, ax::mojom::kFocusable, ax::mojom::kHorizontal, ax::mojom::kHovered, ax::mojom::kIgnored, ax::mojom::kInvisible, ax::mojom::kLinked, ax::mojom::kMultiline, ax::mojom::kMultiselectable, ax::mojom::kNone, ax::mojom::kProtected, ax::mojom::kRequired, ax::mojom::kRichlyEditable, ax::mojom::kVertical, and ax::mojom::kVisited.

Referenced by TEST().

◆ ParseStringAttribute()

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

Definition at line 1471 of file ax_enum_util.cc.

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

References ax::mojom::kAccessKey, ax::mojom::kAriaInvalidValue, ax::mojom::kAutoComplete, ax::mojom::kChildTreeId, ax::mojom::kClassName, ax::mojom::kContainerLiveRelevant, ax::mojom::kContainerLiveStatus, ax::mojom::kDescription, ax::mojom::kDisplay, ax::mojom::kFontFamily, ax::mojom::kHtmlTag, ax::mojom::kIdentifier, ax::mojom::kImageAnnotation, ax::mojom::kImageDataUrl, ax::mojom::kInnerHtml, ax::mojom::kInputType, ax::mojom::kKeyShortcuts, ax::mojom::kLanguage, ax::mojom::kLiveRelevant, ax::mojom::kLiveStatus, ax::mojom::kName, ax::mojom::kNone, ax::mojom::kPlaceholder, ax::mojom::kRole, ax::mojom::kRoleDescription, ax::mojom::kTooltip, ax::mojom::kUrl, and ax::mojom::kValue.

Referenced by TEST().

◆ ParseStringListAttribute()

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

Definition at line 2007 of file ax_enum_util.cc.

2008 {
2009 if (0 == strcmp(string_list_attribute, "none"))
2011 if (0 == strcmp(string_list_attribute, "customActionDescriptions"))
2014}

References ax::mojom::kCustomActionDescriptions, and ax::mojom::kNone.

Referenced by TEST().

◆ ParseTextAffinity()

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

Definition at line 2836 of file ax_enum_util.cc.

2836 {
2837 if (0 == strcmp(text_affinity, "none"))
2839 if (0 == strcmp(text_affinity, "downstream"))
2841 if (0 == strcmp(text_affinity, "upstream"))
2844}

References ax::mojom::kDownstream, ax::mojom::kNone, and ax::mojom::kUpstream.

Referenced by TEST().

◆ ParseTextAlign()

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

Definition at line 2314 of file ax_enum_util.cc.

2314 {
2315 if (0 == strcmp(text_align, "none"))
2317 if (0 == strcmp(text_align, "left"))
2319 if (0 == strcmp(text_align, "right"))
2321 if (0 == strcmp(text_align, "center"))
2323 if (0 == strcmp(text_align, "justify"))
2326}

References ax::mojom::kCenter, ax::mojom::kJustify, ax::mojom::kLeft, ax::mojom::kNone, and ax::mojom::kRight.

Referenced by TEST().

◆ ParseTextBoundary()

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

Definition at line 2219 of file ax_enum_util.cc.

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

References ax::mojom::kCharacter, ax::mojom::kFormat, ax::mojom::kLineEnd, ax::mojom::kLineStart, ax::mojom::kLineStartOrEnd, ax::mojom::kObject, ax::mojom::kPageEnd, ax::mojom::kPageStart, ax::mojom::kPageStartOrEnd, ax::mojom::kParagraphEnd, ax::mojom::kParagraphStart, ax::mojom::kParagraphStartOrEnd, ax::mojom::kSentenceEnd, ax::mojom::kSentenceStart, ax::mojom::kSentenceStartOrEnd, ax::mojom::kWebPage, ax::mojom::kWordEnd, ax::mojom::kWordStart, and ax::mojom::kWordStartOrEnd.

Referenced by TEST().

◆ ParseTextDecorationStyle()

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

Definition at line 2280 of file ax_enum_util.cc.

2281 {
2282 if (0 == strcmp(text_decoration_style, "none"))
2284 if (0 == strcmp(text_decoration_style, "solid"))
2286 if (0 == strcmp(text_decoration_style, "dashed"))
2288 if (0 == strcmp(text_decoration_style, "dotted"))
2290 if (0 == strcmp(text_decoration_style, "double"))
2292 if (0 == strcmp(text_decoration_style, "wavy"))
2295}

References ax::mojom::kDashed, ax::mojom::kDotted, ax::mojom::kDouble, ax::mojom::kNone, ax::mojom::kSolid, and ax::mojom::kWavy.

Referenced by TEST().

◆ ParseTextDirection()

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

Definition at line 2345 of file ax_enum_util.cc.

2345 {
2346 if (0 == strcmp(text_direction, "none"))
2348 if (0 == strcmp(text_direction, "ltr"))
2350 if (0 == strcmp(text_direction, "rtl"))
2352 if (0 == strcmp(text_direction, "ttb"))
2354 if (0 == strcmp(text_direction, "btt"))
2357}

References ax::mojom::kBtt, ax::mojom::kLtr, ax::mojom::kNone, ax::mojom::kRtl, and ax::mojom::kTtb.

Referenced by TEST().

◆ ParseTextPosition()

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

Definition at line 2372 of file ax_enum_util.cc.

2372 {
2373 if (0 == strcmp(text_position, "none"))
2375 if (0 == strcmp(text_position, "subscript"))
2377 if (0 == strcmp(text_position, "superscript"))
2380}

References ax::mojom::kNone, ax::mojom::kSubscript, and ax::mojom::kSuperscript.

Referenced by TEST().

◆ ParseTextStyle()

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

Definition at line 2401 of file ax_enum_util.cc.

2401 {
2402 if (0 == strcmp(text_style, "none"))
2404 if (0 == strcmp(text_style, "bold"))
2406 if (0 == strcmp(text_style, "italic"))
2408 if (0 == strcmp(text_style, "underline"))
2410 if (0 == strcmp(text_style, "lineThrough"))
2412 if (0 == strcmp(text_style, "overline"))
2415}

References ax::mojom::kBold, ax::mojom::kItalic, ax::mojom::kLineThrough, ax::mojom::kNone, ax::mojom::kOverline, and ax::mojom::kUnderline.

Referenced by TEST().

◆ ParseTreeOrder()

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

Definition at line 2863 of file ax_enum_util.cc.

2863 {
2864 if (0 == strcmp(tree_order, "none"))
2866 if (0 == strcmp(tree_order, "undefined"))
2868 if (0 == strcmp(tree_order, "before"))
2870 if (0 == strcmp(tree_order, "equal"))
2872 if (0 == strcmp(tree_order, "after"))
2875}

References ax::mojom::kAfter, ax::mojom::kBefore, ax::mojom::kEqual, ax::mojom::kNone, and ax::mojom::kUndefined.

Referenced by TEST().

◆ 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

References BASE_DCHECK, g_active_popup_ax_unique_id, and GetActivePopupAxUniqueId().

◆ 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}

References ax::mojom::kArticle, ax::mojom::kDefinition, ax::mojom::kDescriptionList, ax::mojom::kDescriptionListTerm, ax::mojom::kDocument, ax::mojom::kGraphicsDocument, ax::mojom::kGrid, ax::mojom::kImage, ax::mojom::kImageMap, ax::mojom::kList, ax::mojom::kListItem, ax::mojom::kProgressIndicator, ax::mojom::kRootWebArea, ax::mojom::kTerm, ax::mojom::kTimer, ax::mojom::kToolbar, ax::mojom::kTooltip, and ax::mojom::kWebArea.

Referenced by ui::AXNodeData::IsReadOnlyOrDisabled().

◆ 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}
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)
const size_t start

References length, start, and StringSearch().

◆ 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}
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)

References StringSearchBasic().

Referenced by StringCompareICU().

◆ 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}

Referenced by StringSearch().

◆ SupportsExpandCollapse()

◆ 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}

References ax::mojom::kComment, ax::mojom::kListItem, ax::mojom::kRow, ax::mojom::kTabList, and ax::mojom::kTreeItem.

Referenced by TEST().

◆ SupportsOrientation()

◆ SupportsSelected()

◆ 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}

References ax::mojom::kCheckBox, ax::mojom::kMenuItemCheckBox, ax::mojom::kSwitch, and ax::mojom::kToggleButton.

Referenced by ui::AXNodeData::IsInvocable(), TEST(), and TEST().

◆ 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)

References ui::AXPosition< AXPositionType, AXNodeType >::swap().

Referenced by TEST_F().

◆ 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}

◆ 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}

References ParseAction().

◆ 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}

References ParseActionFlags().

◆ 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}

References ParseAriaCurrentState().

◆ 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}

References ui::AXNodeData::AddBoolAttribute(), and ParseBoolAttribute().

◆ 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}

References ParseCheckedState().

◆ 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}

References ParseCommand().

◆ TEST() [7/215]

ui::TEST ( AXEnumUtilTest  ,
DefaultActionVerb   
)

Definition at line 94 of file ax_enum_util_unittest.cc.

94 {
95 TestEnumStringConversion<ax::mojom::DefaultActionVerb>(
96 ParseDefaultActionVerb);
97}

References ParseDefaultActionVerb().

◆ 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}

References ParseDescriptionFrom().

◆ 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}

References ParseDropeffect().

◆ 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}

References ParseEvent().

◆ 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}

References ParseEventFrom().

◆ 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}

References ui::AXNodeData::AddFloatAttribute(), and ParseFloatAttribute().

◆ 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}

References ParseGesture().

◆ 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}

References ParseHasPopup().

◆ TEST() [15/215]

ui::TEST ( AXEnumUtilTest  ,
ImageAnnotationStatus   
)

Definition at line 237 of file ax_enum_util_unittest.cc.

237 {
238 TestEnumStringConversion<ax::mojom::ImageAnnotationStatus>(
239 ParseImageAnnotationStatus);
240}

References ParseImageAnnotationStatus().

◆ 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}

References ui::AXNodeData::AddIntAttribute(), and ParseIntAttribute().

◆ 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}

References ui::AXNodeData::AddIntListAttribute(), and ParseIntListAttribute().

◆ 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}

References ParseInvalidState().

◆ 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}

References ParseListStyle().

◆ 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}

References ParseMarkerType().

◆ 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}

References ParseMoveDirection().

◆ 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}

References ParseMutation().

◆ 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}

References ParseNameFrom().

◆ 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}

References ParseRestriction().

◆ 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}

References ParseRole().

◆ 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}

References ParseSortDirection().

◆ 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}

References ParseState().

◆ 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}

References ui::AXNodeData::AddStringAttribute(), and ParseStringAttribute().

◆ TEST() [29/215]

ui::TEST ( AXEnumUtilTest  ,
StringListAttribute   
)

Definition at line 133 of file ax_enum_util_unittest.cc.

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

References ui::AXNodeData::AddStringListAttribute(), and ParseStringListAttribute().

◆ 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>(
154 ParseTextDecorationStyle);
155}

References ParseTextDecorationStyle().

◆ 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}

References ParseTextAffinity().

◆ 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}

References ParseTextAlign().

◆ 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}

References ParseTextBoundary().

◆ 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}

References ParseTextDirection().

◆ 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}

References ParseTextPosition().

◆ 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}

References ParseTextStyle().

◆ 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}

References ParseTreeOrder().

◆ 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();
423 update.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kActivedescendantId,
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}
std::vector< AXNodeData > nodes

References ui::AXEventGenerator::ACTIVE_DESCENDANT_CHANGED, ax::mojom::kActivedescendantId, ax::mojom::kListBox, ax::mojom::kListBoxOption, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXEventGenerator::RELATED_NODE_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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}

References ui::AXEventGenerator::ACTIVE_DESCENDANT_CHANGED, ax::mojom::kActivedescendantId, ax::mojom::kGenericContainer, ax::mojom::kGroup, ax::mojom::kRootWebArea, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::node_id_to_clear, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXEventGenerator::RELATED_NODE_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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));
632 EXPECT_TRUE(
633 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 1));
634 EXPECT_TRUE(
635 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 3));
636}

References ui::AXEventGenerator::CHILDREN_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::SUBTREE_CREATED, and ui::AXTree::Unserialize().

◆ 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}

References ui::AXEventGenerator::ClearEvents(), ax::mojom::kLiveStatus, ui::AXEventGenerator::LIVE_REGION_CREATED, ui::AXEventGenerator::LIVE_STATUS_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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));
1990 EXPECT_TRUE(
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}

References ui::AXEventGenerator::BUSY_CHANGED, ax::mojom::kBusy, ui::AXEventGenerator::LAYOUT_INVALIDATED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTree::Unserialize(), and ui::AXEventGenerator::WIN_IACCESSIBLE_STATE_CHANGED.

◆ 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));
2118 EXPECT_TRUE(
2119 HasEvent(event_generator, AXEventGenerator::Event::ATOMIC_CHANGED, 1));
2120}

References ui::AXEventGenerator::ATOMIC_CHANGED, ax::mojom::kLiveAtomic, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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));
610 EXPECT_TRUE(
611 HasEvent(event_generator, AXEventGenerator::Event::NAME_CHANGED, 2));
612 EXPECT_TRUE(
613 HasEvent(event_generator, AXEventGenerator::Event::NAME_CHANGED, 3));
614}

References ax::mojom::kBusy, ax::mojom::kContainerLiveStatus, ax::mojom::kLiveStatus, ax::mojom::kName, ax::mojom::kStaticText, ui::AXEventGenerator::NAME_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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}

References ui::AXEventGenerator::CHECKED_STATE_CHANGED, ax::mojom::kCheckBox, ax::mojom::kTrue, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTree::Unserialize(), and ui::AXEventGenerator::WIN_IACCESSIBLE_STATE_CHANGED.

◆ 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));
2100 EXPECT_TRUE(
2101 HasEvent(event_generator, AXEventGenerator::Event::CONTROLS_CHANGED, 1));
2102 EXPECT_TRUE(HasEvent(event_generator,
2103 AXEventGenerator::Event::RELATED_NODE_CHANGED, 1));
2104}

References ui::AXEventGenerator::CONTROLS_CHANGED, ax::mojom::kControlsIds, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXEventGenerator::RELATED_NODE_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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;
458 update.nodes[3].role = ax::mojom::Role::kAlertDialog;
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));
463 EXPECT_TRUE(
464 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 1));
465 EXPECT_TRUE(HasEvent(event_generator,
466 AXEventGenerator::Event::LIVE_REGION_CREATED, 2));
467 EXPECT_TRUE(
468 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 2));
469 EXPECT_TRUE(
470 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 3));
471 EXPECT_TRUE(
472 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 4));
473}

References ui::AXEventGenerator::ALERT, ui::AXEventGenerator::CHILDREN_CHANGED, ax::mojom::kAlert, ax::mojom::kAlertDialog, ax::mojom::kLiveStatus, ui::AXEventGenerator::LIVE_REGION_CREATED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::SUBTREE_CREATED, and ui::AXTree::Unserialize().

◆ 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}

References ui::AXEventGenerator::DESCRIPTION_CHANGED, ax::mojom::kDescription, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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}

References ui::AXEventGenerator::DOCUMENT_SELECTION_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTreeData::sel_focus_object_id, ui::AXTreeData::sel_focus_offset, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTree::Unserialize().

◆ 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}

References ui::AXEventGenerator::DOCUMENT_TITLE_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTreeData::title, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTree::Unserialize().

◆ 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}

References ui::AXEventGenerator::DROPEFFECT_CHANGED, ax::mojom::kCopy, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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));
235 EXPECT_TRUE(
236 HasEvent(event_generator, AXEventGenerator::Event::ROW_COUNT_CHANGED, 2));
237 EXPECT_TRUE(
238 HasEvent(event_generator, AXEventGenerator::Event::STATE_CHANGED, 3));
239 EXPECT_TRUE(HasEvent(event_generator,
240 AXEventGenerator::Event::WIN_IACCESSIBLE_STATE_CHANGED,
241 3));
242 EXPECT_TRUE(
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}

References ui::AXEventGenerator::COLLAPSED, ui::AXEventGenerator::EXPANDED, ax::mojom::kExpanded, ax::mojom::kPopUpButton, ax::mojom::kRootWebArea, ax::mojom::kRow, ax::mojom::kTable, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::ROW_COUNT_CHANGED, ui::AXEventGenerator::STATE_CHANGED, ui::AXTree::Unserialize(), and ui::AXEventGenerator::WIN_IACCESSIBLE_STATE_CHANGED.

◆ 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));
330 EXPECT_TRUE(
331 HasEvent(event_generator, AXEventGenerator::Event::VALUE_CHANGED, 1));
332}

References ax::mojom::kSlider, ax::mojom::kValueForRange, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTree::Unserialize(), and ui::AXEventGenerator::VALUE_CHANGED.

◆ 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));
2072 EXPECT_TRUE(
2073 HasEvent(event_generator, AXEventGenerator::Event::FLOW_FROM_CHANGED, 3));
2074 EXPECT_TRUE(
2075 HasEvent(event_generator, AXEventGenerator::Event::FLOW_FROM_CHANGED, 5));
2076 EXPECT_TRUE(
2077 HasEvent(event_generator, AXEventGenerator::Event::FLOW_FROM_CHANGED, 6));
2078 EXPECT_TRUE(
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

References ui::AXEventGenerator::FLOW_FROM_CHANGED, ui::AXEventGenerator::FLOW_TO_CHANGED, ax::mojom::kFlowtoIds, ax::mojom::kGenericContainer, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXEventGenerator::RELATED_NODE_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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));
205 EXPECT_TRUE(
206 HasEvent(event_generator, AXEventGenerator::Event::FOCUS_CHANGED, 2));
207}

References ui::AXEventGenerator::FOCUS_CHANGED, ui::AXTreeData::focus_id, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTree::Unserialize().

◆ 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}

References ui::AXEventGenerator::FOCUS_CHANGED, ui::AXTreeData::focus_id, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTree::Unserialize().

◆ 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));
2150 EXPECT_TRUE(
2151 HasEvent(event_generator, AXEventGenerator::Event::GRABBED_CHANGED, 1));
2152}

References ui::AXEventGenerator::GRABBED_CHANGED, ax::mojom::kGrabbed, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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));
2166 EXPECT_TRUE(
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}

References ui::AXEventGenerator::HASPOPUP_CHANGED, ax::mojom::kTrue, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTree::Unserialize(), and ui::AXEventGenerator::WIN_IACCESSIBLE_STATE_CHANGED.

◆ 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));
1246 EXPECT_TRUE(
1247 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 2));
1248 EXPECT_TRUE(
1249 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 3));
1250 EXPECT_TRUE(
1251 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 3));
1252}

References ui::AXEventGenerator::IGNORED_CHANGED, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::SUBTREE_CREATED, and ui::AXTree::Unserialize().

◆ 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));
1295 EXPECT_TRUE(
1296 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 2));
1297 EXPECT_TRUE(
1298 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 3));
1299 EXPECT_TRUE(
1300 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 4));
1301 EXPECT_TRUE(
1302 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 4));
1303}

References ui::AXEventGenerator::CHILDREN_CHANGED, ui::AXEventGenerator::IGNORED_CHANGED, ax::mojom::kGroup, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::SUBTREE_CREATED, and ui::AXTree::Unserialize().

◆ 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));
1347 EXPECT_TRUE(
1348 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 2));
1349 EXPECT_TRUE(
1350 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 1));
1351 EXPECT_TRUE(
1352 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 3));
1353 EXPECT_TRUE(
1354 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 3));
1355}

References ui::AXEventGenerator::CHILDREN_CHANGED, ui::AXEventGenerator::IGNORED_CHANGED, ax::mojom::kGroup, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::SUBTREE_CREATED, and ui::AXTree::Unserialize().

◆ 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));
1430 EXPECT_TRUE(
1431 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 5));
1432 EXPECT_TRUE(
1433 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 6));
1434 EXPECT_TRUE(
1435 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 7));
1436 EXPECT_TRUE(
1437 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 6));
1438 EXPECT_TRUE(
1439 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 7));
1440 EXPECT_TRUE(
1441 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 8));
1442}

References ui::AXEventGenerator::CHILDREN_CHANGED, ui::AXEventGenerator::IGNORED_CHANGED, ax::mojom::kGroup, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::SUBTREE_CREATED, and ui::AXTree::Unserialize().

◆ 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));
1517 EXPECT_TRUE(
1518 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 5));
1519 EXPECT_TRUE(
1520 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 6));
1521 EXPECT_TRUE(
1522 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 1));
1523 EXPECT_TRUE(
1524 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 6));
1525}

References ui::AXEventGenerator::CHILDREN_CHANGED, ui::AXEventGenerator::IGNORED_CHANGED, ax::mojom::kGroup, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::SUBTREE_CREATED, and ui::AXTree::Unserialize().

◆ 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));
1600 EXPECT_TRUE(
1601 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 5));
1602 EXPECT_TRUE(
1603 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 1));
1604 EXPECT_TRUE(
1605 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 6));
1606 EXPECT_TRUE(
1607 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 7));
1608 EXPECT_TRUE(
1609 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 1));
1610 EXPECT_TRUE(
1611 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 8));
1612}

References ui::AXEventGenerator::CHILDREN_CHANGED, ui::AXEventGenerator::IGNORED_CHANGED, ax::mojom::kGroup, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::SUBTREE_CREATED, and ui::AXTree::Unserialize().

◆ 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));
1677 EXPECT_TRUE(
1678 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 1));
1679 EXPECT_TRUE(
1680 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 1));
1681 EXPECT_TRUE(
1682 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 3));
1683}

References ui::AXEventGenerator::IGNORED_CHANGED, ax::mojom::kGroup, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::SUBTREE_CREATED, and ui::AXTree::Unserialize().

◆ 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));
1759 EXPECT_TRUE(
1760 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 1));
1761 EXPECT_TRUE(
1762 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 2));
1763 EXPECT_TRUE(
1764 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 2));
1765 EXPECT_TRUE(
1766 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 7));
1767}

References ui::AXEventGenerator::CHILDREN_CHANGED, ui::AXEventGenerator::IGNORED_CHANGED, ax::mojom::kGroup, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::SUBTREE_CREATED, and ui::AXTree::Unserialize().

◆ 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}

References ui::AXEventGenerator::IMAGE_ANNOTATION_CHANGED, ax::mojom::kImageAnnotation, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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}

References ui::AXEventGenerator::IMAGE_ANNOTATION_CHANGED, ax::mojom::kAnnotationSucceeded, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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));
1960 EXPECT_TRUE(
1961 HasEvent(event_generator, AXEventGenerator::Event::FLOW_FROM_CHANGED, 1));
1962 EXPECT_TRUE(
1963 HasEvent(event_generator, AXEventGenerator::Event::FLOW_FROM_CHANGED, 2));
1964 EXPECT_TRUE(
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}
const uintptr_t id

References ui::AXEventGenerator::DESCRIBED_BY_CHANGED, ui::AXEventGenerator::FLOW_FROM_CHANGED, ui::AXEventGenerator::FLOW_TO_CHANGED, id, ax::mojom::kDescribedbyIds, ax::mojom::kFlowtoIds, ax::mojom::kLabelledbyIds, ui::AXEventGenerator::LABELED_BY_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXEventGenerator::RELATED_NODE_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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));
1921 EXPECT_TRUE(
1922 HasEvent(event_generator, AXEventGenerator::Event::SET_SIZE_CHANGED, 4));
1923}

References ui::AXEventGenerator::HIERARCHICAL_LEVEL_CHANGED, id, ax::mojom::kHierarchicalLevel, ax::mojom::kPosInSet, ax::mojom::kSetSize, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXEventGenerator::POSITION_IN_SET_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::SET_SIZE_CHANGED, and ui::AXTree::Unserialize().

◆ 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}

References ui::AXEventGenerator::INVALID_STATUS_CHANGED, ax::mojom::kTextField, ax::mojom::kTrue, ax::mojom::kValue, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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));
520 EXPECT_TRUE(
521 HasEvent(event_generator, AXEventGenerator::Event::NAME_CHANGED, 2));
522 EXPECT_TRUE(
523 HasEvent(event_generator, AXEventGenerator::Event::NAME_CHANGED, 3));
524}

References ax::mojom::kContainerLiveStatus, ax::mojom::kLiveStatus, ax::mojom::kName, ax::mojom::kStaticText, ui::AXEventGenerator::LIVE_REGION_CHANGED, ui::AXEventGenerator::LIVE_REGION_NODE_CHANGED, ui::AXEventGenerator::NAME_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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}

References ui::AXEventGenerator::CHECKED_STATE_CHANGED, ui::AXEventGenerator::DESCRIPTION_CHANGED, ax::mojom::kContainerLiveStatus, ax::mojom::kDescription, ax::mojom::kLiveStatus, ax::mojom::kName, ax::mojom::kStaticText, ax::mojom::kTrue, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTree::Unserialize(), and ui::AXEventGenerator::WIN_IACCESSIBLE_STATE_CHANGED.

◆ 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}

References ax::mojom::kLiveRelevant, ui::AXEventGenerator::LIVE_RELEVANT_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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));
68 EXPECT_TRUE(
69 HasEvent(event_generator, AXEventGenerator::Event::LOAD_COMPLETE, 2));
70 EXPECT_TRUE(
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));
82 EXPECT_TRUE(
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));
98 EXPECT_TRUE(
99 HasEvent(event_generator, AXEventGenerator::Event::LOAD_COMPLETE, 4));
100 EXPECT_TRUE(
101 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 4));
102}

References ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ax::mojom::kUrl, ui::AXEventGenerator::LOAD_COMPLETE, ui::AXTreeData::loaded, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::SUBTREE_CREATED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTree::Unserialize().

◆ 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));
44 EXPECT_TRUE(
45 HasEvent(event_generator, AXEventGenerator::Event::LOAD_COMPLETE, 1));
46}

References ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXEventGenerator::LOAD_COMPLETE, ui::AXTreeData::loaded, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTree::Unserialize().

◆ 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));
124 EXPECT_TRUE(
125 HasEvent(event_generator, AXEventGenerator::Event::LOAD_START, 2));
126 EXPECT_TRUE(
127 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 2));
128}

References ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXEventGenerator::LOAD_START, ui::AXTreeData::loaded, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::SUBTREE_CREATED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTree::Unserialize().

◆ 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();
967 update.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kActivedescendantId,
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}

References ui::AXEventGenerator::ACTIVE_DESCENDANT_CHANGED, ax::mojom::kActivedescendantId, ax::mojom::kMenu, ax::mojom::kMenuListOption, ui::AXEventGenerator::MENU_ITEM_SELECTED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXEventGenerator::RELATED_NODE_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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));
2204 EXPECT_TRUE(
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}

References ax::mojom::kMultiline, ui::AXEventGenerator::MULTILINE_STATE_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::STATE_CHANGED, ui::AXTree::Unserialize(), and ui::AXEventGenerator::WIN_IACCESSIBLE_STATE_CHANGED.

◆ 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));
2015 EXPECT_TRUE(
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}

References ax::mojom::kGrid, ax::mojom::kMultiselectable, ui::AXEventGenerator::MULTISELECTABLE_STATE_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::STATE_CHANGED, ui::AXTree::Unserialize(), and ui::AXEventGenerator::WIN_IACCESSIBLE_STATE_CHANGED.

◆ 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));
913 EXPECT_TRUE(
914 HasEvent(event_generator, AXEventGenerator::Event::NAME_CHANGED, 2));
915}

References ax::mojom::kName, ui::AXEventGenerator::NAME_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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));
1004 EXPECT_TRUE(
1005 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 2));
1006 EXPECT_TRUE(
1007 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 4));
1008}

References ui::AXEventGenerator::CHILDREN_CHANGED, ui::AXEventGenerator::IGNORED_CHANGED, ax::mojom::kArticle, ax::mojom::kGroup, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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));
1040 EXPECT_TRUE(
1041 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 2));
1042 EXPECT_TRUE(
1043 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 4));
1044}

References ui::AXEventGenerator::CHILDREN_CHANGED, ui::AXEventGenerator::IGNORED_CHANGED, ax::mojom::kArticle, ax::mojom::kGroup, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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));
1073 EXPECT_TRUE(
1074 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 2));
1075 EXPECT_TRUE(
1076 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 4));
1077 EXPECT_TRUE(
1078 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 4));
1079}

References ui::AXEventGenerator::CHILDREN_CHANGED, ui::AXEventGenerator::IGNORED_CHANGED, ax::mojom::kArticle, ax::mojom::kGroup, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::SUBTREE_CREATED, and ui::AXTree::Unserialize().

◆ 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));
1112 EXPECT_TRUE(
1113 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 2));
1114 EXPECT_TRUE(
1115 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 4));
1116 EXPECT_TRUE(
1117 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 4));
1118}

References ui::AXEventGenerator::CHILDREN_CHANGED, ui::AXEventGenerator::IGNORED_CHANGED, ax::mojom::kArticle, ax::mojom::kGroup, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::SUBTREE_CREATED, and ui::AXTree::Unserialize().

◆ 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));
843 EXPECT_TRUE(
844 HasEvent(event_generator,
845 AXEventGenerator::Event::ATK_TEXT_OBJECT_ATTRIBUTE_CHANGED, 2));
846 EXPECT_TRUE(
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}

References ui::AXEventGenerator::ATK_TEXT_OBJECT_ATTRIBUTE_CHANGED, ax::mojom::kTextAlign, ax::mojom::kTextIndent, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXEventGenerator::OBJECT_ATTRIBUTE_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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));
885 EXPECT_TRUE(
886 HasEvent(event_generator, AXEventGenerator::Event::CONTROLS_CHANGED, 6));
887 EXPECT_TRUE(
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}

References ui::AXEventGenerator::CONTROLS_CHANGED, ax::mojom::kAriaCellColumnIndex, ax::mojom::kControlsIds, ax::mojom::kFontSize, ax::mojom::kLanguage, ax::mojom::kModal, ui::AXEventGenerator::LANGUAGE_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXEventGenerator::OTHER_ATTRIBUTE_CHANGED, ui::AXEventGenerator::RELATED_NODE_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::TEXT_ATTRIBUTE_CHANGED, and ui::AXTree::Unserialize().

◆ 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));
656 EXPECT_TRUE(
657 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 1));
658}

References ui::AXEventGenerator::CHILDREN_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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));
678 EXPECT_TRUE(
679 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 1));
680}

References ui::AXEventGenerator::CHILDREN_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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));
2037 EXPECT_TRUE(
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}

References ax::mojom::kRequired, ax::mojom::kTextField, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXEventGenerator::REQUIRED_STATE_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::STATE_CHANGED, ui::AXTree::Unserialize(), and ui::AXEventGenerator::WIN_IACCESSIBLE_STATE_CHANGED.

◆ 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));
944 EXPECT_TRUE(
945 HasEvent(event_generator, AXEventGenerator::Event::ROLE_CHANGED, 1));
946}

References ax::mojom::kCheckBox, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXEventGenerator::ROLE_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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));
693 EXPECT_TRUE(
694 HasEvent(event_generator,
695 AXEventGenerator::Event::SCROLL_HORIZONTAL_POSITION_CHANGED, 1));
696}

References ax::mojom::kScrollX, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::SCROLL_HORIZONTAL_POSITION_CHANGED, and ui::AXTree::Unserialize().

◆ 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));
709 EXPECT_TRUE(
710 HasEvent(event_generator,
711 AXEventGenerator::Event::SCROLL_VERTICAL_POSITION_CHANGED, 1));
712}

References ax::mojom::kScrollY, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::SCROLL_VERTICAL_POSITION_CHANGED, and ui::AXTree::Unserialize().

◆ 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;
274 update.nodes[3].role = ax::mojom::Role::kListBoxOption;
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));
280 EXPECT_TRUE(
281 HasEvent(event_generator, AXEventGenerator::Event::SELECTED_CHANGED, 3));
282 EXPECT_TRUE(HasEvent(event_generator,
283 AXEventGenerator::Event::WIN_IACCESSIBLE_STATE_CHANGED,
284 3));
285 EXPECT_TRUE(
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}

References ax::mojom::kListBoxOption, ax::mojom::kMenu, ax::mojom::kMenuItem, ax::mojom::kRootWebArea, ax::mojom::kSelected, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::SELECTED_CHANGED, ui::AXEventGenerator::SELECTED_CHILDREN_CHANGED, ui::AXTree::Unserialize(), and ui::AXEventGenerator::WIN_IACCESSIBLE_STATE_CHANGED.

◆ 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));
1880 EXPECT_TRUE(
1881 HasEvent(event_generator, AXEventGenerator::Event::LANGUAGE_CHANGED, 5));
1882 EXPECT_TRUE(HasEvent(event_generator,
1883 AXEventGenerator::Event::PLACEHOLDER_CHANGED, 6));
1884}

References ui::AXEventGenerator::ACCESS_KEY_CHANGED, ui::AXEventGenerator::CLASS_NAME_CHANGED, id, ax::mojom::kAccessKey, ax::mojom::kClassName, ui::AXEventGenerator::KEY_SHORTCUTS_CHANGED, ax::mojom::kKeyShortcuts, ax::mojom::kLanguage, ax::mojom::kPlaceholder, ui::AXEventGenerator::LANGUAGE_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXEventGenerator::PLACEHOLDER_CHANGED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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));
309 EXPECT_TRUE(
310 HasEvent(event_generator, AXEventGenerator::Event::VALUE_CHANGED, 1));
311}

References ax::mojom::kTextField, ax::mojom::kValue, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTree::Unserialize(), and ui::AXEventGenerator::VALUE_CHANGED.

◆ 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));
1142 EXPECT_TRUE(
1143 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 1));
1144 EXPECT_TRUE(
1145 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 2));
1146 EXPECT_TRUE(
1147 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 2));
1148}

References ui::AXEventGenerator::CHILDREN_CHANGED, ui::AXEventGenerator::IGNORED_CHANGED, ax::mojom::kArticle, ax::mojom::kGroup, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::SUBTREE_CREATED, and ui::AXTree::Unserialize().

◆ 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}

References ax::mojom::kActiveSuggestion, ax::mojom::kBackgroundColor, ax::mojom::kBold, ax::mojom::kColor, ax::mojom::kDotted, ax::mojom::kFontFamily, ax::mojom::kFontSize, ax::mojom::kFontWeight, ax::mojom::kGrammar, ax::mojom::kMarkerEnds, ax::mojom::kMarkerStarts, ax::mojom::kMarkerTypes, ax::mojom::kRtl, ax::mojom::kSolid, ax::mojom::kSpelling, ax::mojom::kSuggestion, ax::mojom::kSuperscript, ax::mojom::kTextDirection, ax::mojom::kTextMatch, ax::mojom::kTextOverlineStyle, ax::mojom::kTextPosition, ax::mojom::kTextStrikethroughStyle, ax::mojom::kTextStyle, ax::mojom::kTextUnderlineStyle, ax::mojom::kWavy, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::TEXT_ATTRIBUTE_CHANGED, and ui::AXTree::Unserialize().

◆ 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));
1171 EXPECT_TRUE(
1172 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 1));
1173 EXPECT_TRUE(
1174 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 2));
1175 EXPECT_TRUE(
1176 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 3));
1177 EXPECT_TRUE(
1178 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 3));
1179}

References ui::AXEventGenerator::CHILDREN_CHANGED, ui::AXEventGenerator::IGNORED_CHANGED, ax::mojom::kArticle, ax::mojom::kGroup, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::SUBTREE_CREATED, and ui::AXTree::Unserialize().

◆ 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));
1202 EXPECT_TRUE(
1203 HasEvent(event_generator, AXEventGenerator::Event::CHILDREN_CHANGED, 1));
1204 EXPECT_TRUE(
1205 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 2));
1206 EXPECT_TRUE(
1207 HasEvent(event_generator, AXEventGenerator::Event::IGNORED_CHANGED, 3));
1208 EXPECT_TRUE(
1209 HasEvent(event_generator, AXEventGenerator::Event::SUBTREE_CREATED, 2));
1210}

References ui::AXEventGenerator::CHILDREN_CHANGED, ui::AXEventGenerator::IGNORED_CHANGED, ax::mojom::kArticle, ax::mojom::kGroup, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXEventGenerator::SUBTREE_CREATED, and ui::AXTree::Unserialize().

◆ 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}

References ui::AXNodeData::actions, ax::mojom::kMaxValue, and ui::AXNodeData::state.

◆ TEST() [102/215]

ui::TEST ( AXNodeDataTest  ,
GetAndSetCheckedState   
)

◆ 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

References IsButton(), ui::AXNodeData::IsButtonPressed(), ax::mojom::kButton, ax::mojom::kFalse, ax::mojom::kGenericContainer, ax::mojom::kMixed, ax::mojom::kNone, ax::mojom::kPopUpButton, ax::mojom::kToggleButton, ax::mojom::kTrue, ui::AXNodeData::role, and ui::AXNodeData::SetCheckedState().

◆ 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)
bool IsClickable() const
void SetDefaultActionVerb(ax::mojom::DefaultActionVerb default_action_verb)
ax::mojom::DefaultActionVerb GetDefaultActionVerb() const
std::shared_ptr< const fml::Mapping > data

References base::Contains(), data, ui::AXNodeData::GetDefaultActionVerb(), ui::AXNodeData::IsClickable(), ax::mojom::kButton, ax::mojom::kCheckBox, ax::mojom::kClickAncestor, ax::mojom::kColorWell, ax::mojom::kComboBoxMenuButton, ax::mojom::kDate, ax::mojom::kDateTime, ax::mojom::kDisclosureTriangle, ax::mojom::kDocBackLink, ax::mojom::kDocBiblioRef, ax::mojom::kDocGlossRef, ax::mojom::kDocNoteRef, ax::mojom::kImeCandidate, ax::mojom::kInputTime, ax::mojom::kLink, ax::mojom::kListBox, ax::mojom::kListBoxOption, ax::mojom::kMaxValue, ax::mojom::kMenuItem, ax::mojom::kMenuItemCheckBox, ax::mojom::kMenuItemRadio, ax::mojom::kMenuListOption, ax::mojom::kMinValue, ax::mojom::kNone, ax::mojom::kPdfActionableHighlight, ax::mojom::kPopUpButton, ax::mojom::kPortal, ax::mojom::kRadioButton, ax::mojom::kSearchBox, ax::mojom::kSpinButton, ax::mojom::kSwitch, ax::mojom::kTab, ax::mojom::kTextField, ax::mojom::kTextFieldWithComboBox, ax::mojom::kToggleButton, ui::AXNodeData::role, ui::AXNodeData::SetDefaultActionVerb(), and ToString().

◆ 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)

References data, ax::mojom::kMaxValue, ax::mojom::kMinValue, ui::AXNodeData::role, SupportsToggle(), and ToString().

◆ 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

References ui::AXNodeData::GetHasPopup(), IsButton(), ui::AXNodeData::IsMenuButton(), ax::mojom::kButton, ax::mojom::kGenericContainer, ax::mojom::kMaxValue, ax::mojom::kMenu, ax::mojom::kMinValue, ui::AXNodeData::role, ui::AXNodeData::SetHasPopup(), and ToString().

◆ 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.
311 if (state == ax::mojom::State::kNone)
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

References ui::AXNodeData::AddState(), data, ui::AXNodeData::GetHasPopup(), ui::AXNodeData::HasState(), ax::mojom::kCollapsed, ax::mojom::kComboBoxGrouping, ax::mojom::kComboBoxMenuButton, ax::mojom::kDisclosureTriangle, ax::mojom::kExpanded, ax::mojom::kFalse, ax::mojom::kMaxValue, ax::mojom::kMinValue, ax::mojom::kNone, ax::mojom::kTextFieldWithComboBox, ax::mojom::kTreeItem, ui::AXNodeData::RemoveState(), ui::AXNodeData::role, ui::AXNodeData::SetHasPopup(), ui::AXNodeData::SupportsExpandCollapse(), and ToString().

◆ 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)

References ui::AXNodeData::AddFloatAttribute(), ui::AXNodeData::AddIntAttribute(), ui::AXNodeData::AddStringAttribute(), ui::AXNodeData::GetStringAttribute(), ui::AXNodeData::GetTextStyles(), ax::mojom::kColor, ax::mojom::kFontFamily, ax::mojom::kFontSize, ax::mojom::kTooltip, ui::AXNodeData::RemoveIntAttribute(), and ui::AXNodeData::RemoveStringAttribute().

◆ 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
465 AXTreeUpdate update;
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)
std::vector< int32_t > child_ids

References ui::TestAXNodeWrapper::ax_platform_node(), ui::AXNodeData::child_ids, ui::AXPlatformNode::FromNativeViewAccessible(), ui::TestAXNodeWrapper::GetOrCreate(), ui::AXNodeData::id, kAXModeComplete(), ax::mojom::kStaticText, ax::mojom::kWebArea, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXPlatformNode::NotifyAddAXModeFlags(), base::NumberToString(), ui::AXNodeData::role, ui::AXTree::root(), and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ TEST() [110/215]

ui::TEST ( AXPlatformNodeBaseTest  ,
GetHypertext   
)

Definition at line 48 of file ax_platform_node_base_unittest.cc.

48 {
49 AXTreeUpdate update;
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)

References ui::TestAXNodeWrapper::ax_platform_node(), ui::AXPlatformNodeBase::ChildAtIndex(), ui::AXPlatformNode::FromNativeViewAccessible(), ui::AXPlatformNodeBase::GetHypertext(), ui::TestAXNodeWrapper::GetOrCreate(), kAXModeComplete(), ax::mojom::kWebArea, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXPlatformNode::NotifyAddAXModeFlags(), ui::AXTree::root(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and base::UTF8ToUTF16().

◆ TEST() [111/215]

ui::TEST ( AXPlatformNodeBaseTest  ,
GetHypertextIgnoredContainerSiblings   
)

Definition at line 91 of file ax_platform_node_base_unittest.cc.

91 {
92 AXTreeUpdate update;
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}

References ui::TestAXNodeWrapper::ax_platform_node(), ui::AXPlatformNodeBase::ChildAtIndex(), ui::AXPlatformNode::FromNativeViewAccessible(), ui::AXPlatformNodeBase::GetHypertext(), ui::TestAXNodeWrapper::GetOrCreate(), kAXModeComplete(), ax::mojom::kGenericContainer, ax::mojom::kIgnored, ax::mojom::kWebArea, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXPlatformNode::NotifyAddAXModeFlags(), ui::AXTree::root(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and base::UTF8ToUTF16().

◆ TEST() [112/215]

ui::TEST ( AXPlatformNodeBaseTest  ,
InnerTextIgnoresInvisibleAndIgnored   
)

Definition at line 156 of file ax_platform_node_base_unittest.cc.

156 {
157 AXTreeUpdate update;
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}

References ui::TestAXNodeWrapper::ax_platform_node(), ui::TestAXNodeWrapper::GetOrCreate(), kAXModeComplete(), ax::mojom::kIgnored, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXPlatformNode::NotifyAddAXModeFlags(), ui::AXTree::root(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and base::UTF8ToUTF16().

◆ 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
227 AXTreeUpdate update;
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)

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::AddState(), ui::TestAXNodeWrapper::ax_platform_node(), ui::AXNodeData::child_ids, ui::AXPlatformNodeBase::GetNativeViewAccessible(), ui::TestAXNodeWrapper::GetOrCreate(), ui::AXPlatformNodeBase::GetSelectedItem(), ui::AXPlatformNodeBase::GetSelectionCount(), ui::AXNodeData::id, kAXModeComplete(), ax::mojom::kFocusable, ax::mojom::kListBox, ax::mojom::kListBoxOption, ax::mojom::kSelected, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXPlatformNode::NotifyAddAXModeFlags(), ui::AXNodeData::role, ui::AXTree::root(), and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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
369 AXTreeUpdate update;
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}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::AddState(), ui::TestAXNodeWrapper::ax_platform_node(), ui::AXNodeData::child_ids, ui::AXPlatformNode::FromNativeViewAccessible(), ui::AXPlatformNodeBase::GetNativeViewAccessible(), ui::TestAXNodeWrapper::GetOrCreate(), ui::AXPlatformNodeBase::GetSelectedItem(), ui::AXPlatformNodeBase::GetSelectionCount(), ui::AXNodeData::id, kAXModeComplete(), ax::mojom::kFocusable, ax::mojom::kGroup, ax::mojom::kListBox, ax::mojom::kListBoxOption, ax::mojom::kMultiselectable, ax::mojom::kSelected, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXPlatformNode::NotifyAddAXModeFlags(), ui::AXNodeData::role, ui::AXTree::root(), and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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
282 AXTreeUpdate update;
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}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::AddState(), ui::TestAXNodeWrapper::ax_platform_node(), ui::AXNodeData::child_ids, ui::AXPlatformNode::FromNativeViewAccessible(), ui::AXPlatformNodeBase::GetNativeViewAccessible(), ui::TestAXNodeWrapper::GetOrCreate(), ui::AXPlatformNodeBase::GetSelectedItem(), ui::AXPlatformNodeBase::GetSelectionCount(), ui::AXNodeData::id, kAXModeComplete(), ax::mojom::kFocusable, ax::mojom::kGroup, ax::mojom::kListBox, ax::mojom::kListBoxOption, ax::mojom::kMultiselectable, ax::mojom::kSelected, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXPlatformNode::NotifyAddAXModeFlags(), ui::AXNodeData::role, ui::AXTree::root(), and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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

References i, and 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

References ui::AXUniqueId::Get().

◆ 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}

References i, and kMaxId.

◆ 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}

References ax::mojom::kComment, ax::mojom::kListItem, ax::mojom::kMaxValue, ax::mojom::kMinValue, ax::mojom::kRow, ax::mojom::kTabList, ax::mojom::kTreeItem, SupportsHierarchicalLevel(), and ToString().

◆ 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}

References ax::mojom::kCheckBox, ax::mojom::kMaxValue, ax::mojom::kMenuItemCheckBox, ax::mojom::kMinValue, ax::mojom::kSwitch, ax::mojom::kToggleButton, SupportsToggle(), and ToString().

◆ 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}

References ax::mojom::kBusy, ax::mojom::kDescription, ax::mojom::kLiveAtomic, ax::mojom::kMaxValueForRange, ax::mojom::kMinValueForRange, ax::mojom::kModal, ax::mojom::kName, ax::mojom::kScrollX, ax::mojom::kScrollXMax, ax::mojom::kScrollXMin, ax::mojom::kStepValueForRange, ax::mojom::kValue, ax::mojom::kValueForRange, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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

References ui::AXNodeData::id, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTree::Unserialize().

◆ 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}

References ui::AXNodeData::child_ids, ui::AXNodeData::id, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTree::Unserialize().

◆ 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}

References ui::AXNodeData::child_ids, ui::AXNodeData::id, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTree::Unserialize().

◆ 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}

References ui::AXNode::children(), ui::AXTree::GetFromId(), ui::AXNode::GetUnignoredChildAtIndex(), ui::AXNode::GetUnignoredChildCount(), ui::AXNode::GetUnignoredIndexInParent(), ui::AXNode::GetUnignoredParent(), ui::AXNode::id(), ax::mojom::kIgnored, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::node_id_to_clear, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTree::root(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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
1718 AXTreeUpdate update;
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}

References base::Contains(), ui::AXTree::GetReverseRelations(), ax::mojom::kActivedescendantId, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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.
379 AXTreeUpdate update;
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}

References ui::AXTree::error(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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}

References ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References ax::mojom::kClipsChildren, ax::mojom::kRootWebArea, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References ax::mojom::kClipsChildren, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References ax::mojom::kClipsChildren, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References ax::mojom::kClipsChildren, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References ax::mojom::kClipsChildren, ax::mojom::kRootWebArea, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References ax::mojom::kScrollX, ax::mojom::kScrollY, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References ui::AXNode::GetFirstChild(), ui::AXTree::GetFromId(), ui::AXNode::GetLastChild(), ui::AXNode::GetNextSibling(), ui::AXNode::GetPreviousSibling(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References ui::AXTree::GetFromId(), ui::AXNode::GetNextSibling(), ui::AXNode::GetNextUnignoredSibling(), ui::AXNode::GetPreviousSibling(), ui::AXNode::GetPreviousUnignoredSibling(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References ui::AXTree::GetFromId(), ui::AXNode::GetNextUnignoredSibling(), ui::AXNode::GetPreviousUnignoredSibling(), ax::mojom::kIgnored, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References ui::AXTree::GetFromId(), ui::AXNode::GetNextUnignoredSibling(), ui::AXNode::GetPreviousUnignoredSibling(), ax::mojom::kIgnored, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References ui::AXTree::GetFromId(), ui::AXNode::GetNextSibling(), ui::AXNode::GetNextUnignoredSibling(), ui::AXNode::GetPreviousSibling(), ui::AXNode::GetPreviousUnignoredSibling(), ax::mojom::kIgnored, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References ui::AXTree::GetFromId(), ui::AXNode::GetNextSibling(), ui::AXNode::GetNextUnignoredSibling(), ui::AXNode::GetPreviousSibling(), ui::AXNode::GetPreviousUnignoredSibling(), ax::mojom::kIgnored, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References ui::AXTree::GetFromId(), ui::AXNode::GetNextSibling(), ui::AXNode::GetNextUnignoredSibling(), ui::AXNode::GetPreviousSibling(), ui::AXNode::GetPreviousUnignoredSibling(), ax::mojom::kIgnored, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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.
833 AXTreeUpdate update;
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}

References ui::AXTree::GetFromId(), ui::AXNode::GetStringAttribute(), ui::AXNode::HasStringAttribute(), ax::mojom::kName, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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.
690 AXTreeUpdate update;
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}

References ui::AXTree::GetFromId(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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 ]
730 AXTreeUpdate update;
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}

References ui::AXTree::GetFromId(), ui::AXNode::GetUnignoredIndexInParent(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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.
788 AXTreeUpdate update;
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}

References ui::AXTree::GetFromId(), ui::AXNode::GetUnignoredIndexInParent(), ax::mojom::kIgnored, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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}

References ax::mojom::kControlsIds, ax::mojom::kFlowtoIds, ax::mojom::kRadioGroupIds, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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}

References base::Contains(), ui::AXTree::GetReverseRelations(), ax::mojom::kLabelledbyIds, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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();
1633 update.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kActivedescendantId,
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}

References base::Contains(), ui::AXTree::GetReverseRelations(), ax::mojom::kActivedescendantId, ax::mojom::kErrormessageId, ax::mojom::kMemberOfId, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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.
403 AXTreeUpdate update;
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}

References ui::AXTree::error(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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.
346 AXTreeUpdate update;
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}

References ui::AXTree::error(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::node_id_to_clear, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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.
363 AXTreeUpdate update;
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}

References ui::AXTree::error(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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
966 AXTreeUpdate update;
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}

References ui::AXNode::data(), ui::AXTree::error(), ui::AXTree::GetFromId(), ui::AXNode::GetUnignoredChildCount(), ui::AXNodeData::HasState(), ax::mojom::kIgnored, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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
997 AXTreeUpdate update;
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}

References ui::AXTree::error(), ui::AXTree::GetFromId(), ui::AXNode::GetUnignoredChildCount(), ax::mojom::kIgnored, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::node_id_to_clear, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ TEST() [158/215]

ui::TEST ( AXTreeTest  ,
NoReparentingIfOnlyRemovedAndChangedNotReAdded   
)

Definition at line 464 of file ax_tree_unittest.cc.

464 {
465 AXNodeData root;
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.
482 AXTreeUpdate update;
483 update.nodes.resize(2);
484 update.nodes[0].id = 2;
485 update.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kActivedescendantId,
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}

References ui::AXNodeData::child_ids, ui::AXTree::error(), ui::AXNodeData::id, ax::mojom::kActivedescendantId, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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
525 AXTreeUpdate update;
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}

References ui::AXTree::error(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ TEST() [160/215]

ui::TEST ( AXTreeTest  ,
NoReparentingOfRootIfNoNewRoot   
)

Definition at line 415 of file ax_tree_unittest.cc.

415 {
416 AXNodeData root;
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
437 AXTreeUpdate update;
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}

References ui::AXNodeData::child_ids, ui::AXNodeData::id, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::node_id_to_clear, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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}

References ui::AXNode::children(), ui::AXNode::GetUnignoredChildAtIndex(), ui::AXNode::GetUnignoredChildCount(), ax::mojom::kIgnored, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTree::root(), and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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
4416 AXTreeUpdate update;
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}

References ui::AXTree::GetFromId(), ax::mojom::kButton, ax::mojom::kCheckBox, ax::mojom::kInlineTextBox, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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}

References ax::mojom::kGenericContainer, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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)

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kArticle, ax::mojom::kList, ax::mojom::kListItem, ax::mojom::kSetSize, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kList, ax::mojom::kListItem, ax::mojom::kPosInSet, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kList, ax::mojom::kListItem, ax::mojom::kPosInSet, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kList, ax::mojom::kListItem, ax::mojom::kPosInSet, ax::mojom::kSetSize, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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
572 AXTreeUpdate update;
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}

References ui::AXTree::error(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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
931 AXTreeUpdate update;
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}

References base::Contains(), ui::AXTree::error(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::node_id_to_clear, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ TEST() [170/215]

ui::TEST ( AXTreeTest  ,
ReparentRootIfRootChanged   
)

Definition at line 607 of file ax_tree_unittest.cc.

607 {
608 AXNodeData root;
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
630 AXTreeUpdate update;
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}

References ui::AXNodeData::child_ids, ui::AXNodeData::id, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::node_id_to_clear, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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) {
1748 AXTreeUpdate update;
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(
1756 ax::mojom::IntListAttribute::kLabelledbyIds, {update.nodes[1].id});
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}

References i, ui::AXTree::int_reverse_relations(), ui::AXTree::intlist_reverse_relations(), ax::mojom::kActivedescendantId, ax::mojom::kLabelledbyIds, ax::mojom::kMemberOfId, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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.
1108 AXTreeUpdate update;
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}

References ax::mojom::kButton, ax::mojom::kCheckBox, ax::mojom::kFalse, ax::mojom::kFocusable, ax::mojom::kTrue, ax::mojom::kVisited, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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
317 AXTreeUpdate update;
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}
std::string ToString() const

References ui::AXNodeData::child_ids, ui::AXNodeData::id, ax::mojom::kButton, ax::mojom::kList, ax::mojom::kListItem, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::ToString().

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kList, ax::mojom::kListItem, ax::mojom::kSetSize, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kList, ax::mojom::kListItem, ax::mojom::kSetSize, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kList, ax::mojom::kListItem, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kList, ax::mojom::kListItem, ax::mojom::kPosInSet, ax::mojom::kSetSize, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kControlsIds, ax::mojom::kGenericContainer, ax::mojom::kMenu, ax::mojom::kMenuItem, ax::mojom::kPopUpButton, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kList, ax::mojom::kListItem, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kMenu, ax::mojom::kMenuItem, ax::mojom::kMenuItemCheckBox, ax::mojom::kMenuItemRadio, ax::mojom::kTab, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kHierarchicalLevel, ax::mojom::kTree, ax::mojom::kTreeItem, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kHierarchicalLevel, ax::mojom::kTree, ax::mojom::kTreeItem, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kGroup, ax::mojom::kListBox, ax::mojom::kListBoxOption, ax::mojom::kListItem, ax::mojom::kMenu, ax::mojom::kMenuBar, ax::mojom::kMenuItemCheckBox, ax::mojom::kMenuItemRadio, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kInvisible, ax::mojom::kListBox, ax::mojom::kListBoxOption, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kIgnored, ax::mojom::kTree, ax::mojom::kTreeItem, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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}

References ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kListItem, ax::mojom::kPosInSet, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kGenericContainer, ax::mojom::kPopUpButton, ax::mojom::kPosInSet, ax::mojom::kSetSize, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kMenuItem, ax::mojom::kMenuListOption, ax::mojom::kMenuListPopup, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kList, ax::mojom::kListItem, ax::mojom::kPosInSet, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kGenericContainer, ax::mojom::kIgnored, ax::mojom::kList, ax::mojom::kListItem, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kList, ax::mojom::kListItem, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetSetSize(), ax::mojom::kMenuListOption, ax::mojom::kMenuListPopup, ax::mojom::kPopUpButton, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kForm, ax::mojom::kGenericContainer, ax::mojom::kName, ax::mojom::kPosInSet, ax::mojom::kRadioButton, ax::mojom::kRadioGroup, ax::mojom::kSetSize, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kList, ax::mojom::kListItem, ax::mojom::kRadioButton, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kTree, ax::mojom::kTreeItem, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTree::SetTreeUpdateInProgressState(), and ui::AXTree::Unserialize().

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kList, ax::mojom::kListItem, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kMenu, ax::mojom::kMenuItem, ax::mojom::kUnknown, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References EXPECT_OPTIONAL_EQ, ui::AXTree::GetFromId(), ui::AXNode::GetPosInSet(), ui::AXNode::GetSetSize(), ax::mojom::kGroup, ax::mojom::kListBox, ax::mojom::kListBoxOption, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References ui::AXTree::error(), ax::mojom::kGenericContainer, ax::mojom::kRootWebArea, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTree::ToString(), and ui::AXTree::Unserialize().

◆ 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}

References ui::AXTree::error(), ax::mojom::kGenericContainer, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTree::ToString(), and ui::AXTree::Unserialize().

◆ 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}

References ui::AXTree::error(), ax::mojom::kList, ax::mojom::kListItem, ax::mojom::kRootWebArea, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTree::ToString(), and ui::AXTree::Unserialize().

◆ 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}

References ui::AXTree::error(), ax::mojom::kGenericContainer, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTree::ToString(), and ui::AXTree::Unserialize().

◆ 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}

References ui::AXTree::error(), ax::mojom::kGenericContainer, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTree::ToString(), and ui::AXTree::Unserialize().

◆ 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}

References ui::AXNode::children(), ui::AXNode::GetUnignoredChildAtIndex(), ui::AXNode::GetUnignoredChildCount(), ui::AXNode::GetUnignoredIndexInParent(), ui::AXNode::GetUnignoredParent(), ui::AXNode::id(), ax::mojom::kIgnored, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTree::root(), and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References ui::AXTree::GetFromId(), ui::AXNode::IsInListMarker(), ax::mojom::kInlineTextBox, ax::mojom::kList, ax::mojom::kListItem, ax::mojom::kListMarker, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References ui::AXNode::children(), ui::AXTree::GetFromId(), ui::AXNode::GetUnignoredChildAtIndex(), ui::AXNode::GetUnignoredChildCount(), ui::AXNode::id(), ax::mojom::kIgnored, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTree::root(), and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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);
853 AXTreeUpdate update;
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}

References ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::node_id_to_clear, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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}

References ui::AXTree::data(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTreeData::title, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTree::Unserialize().

◆ 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);
1018 AXTreeUpdate update;
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}

References ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::node_id_to_clear, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ 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}

References ui::AXTree::GetFromId(), ui::AXNode::GetLastUnignoredChild(), ui::AXNode::id(), ax::mojom::kIgnored, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}
const size_t end

References end, ui::AXTree::GetFromId(), ax::mojom::kIgnored, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTree::root(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNode::UnignoredChildrenBegin(), and ui::AXNode::UnignoredChildrenEnd().

◆ 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}

References ui::AXTree::GetFromId(), ax::mojom::kGenericContainer, ax::mojom::kIgnored, ax::mojom::kName, ax::mojom::kStaticText, ax::mojom::kWebArea, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTree::root(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNode::UnignoredChildrenBegin(), and ui::AXNode::UnignoredChildrenEnd().

◆ 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}

References ax::mojom::kName, ax::mojom::kStaticText, ax::mojom::kWebArea, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTree::root(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNode::UnignoredChildrenBegin(), and ui::AXNode::UnignoredChildrenEnd().

◆ 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}

References ui::AXTree::GetFromId(), ui::AXNode::GetNextUnignoredSibling(), ui::AXNode::GetPreviousUnignoredSibling(), ax::mojom::kIgnored, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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
static int input(yyscan_t yyscanner)

References ui::AXNode::OwnerTree::Selection::anchor_object_id, ui::AXNode::OwnerTree::Selection::anchor_offset, ui::AXTreeID::CreateNewAXTreeID(), ui::AXNode::OwnerTree::Selection::focus_object_id, ui::AXNode::OwnerTree::Selection::focus_offset, ui::TestAXTreeManager::GetTree(), ui::AXTree::GetUnignoredSelection(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, input(), ax::mojom::kGenericContainer, ax::mojom::kIgnored, ui::AXNode::kInvalidAXID, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, TEST_SELECTION, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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
AXRelativeBounds relative_bounds

References ui::AXRelativeBounds::bounds, ui::AXNodeData::child_ids, ui::AXNode::children(), ui::AXNodeData::id, ui::AXNodeData::relative_bounds, and ui::TestAXNodeWrapper::SetScaleFactor().

◆ TEST_F() [2/325]

ui::TEST_F ( AXFragmentRootTest  ,
TestChildAtIndex   
)

Definition at line 425 of file ax_fragment_root_win_unittest.cc.

425 {
426 AXNodeData root;
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

References ui::AXPlatformNodeDelegate::ChildAtIndex(), and ui::AXNodeData::id.

◆ TEST_F() [3/325]

ui::TEST_F ( AXFragmentRootTest  ,
TestFragmentRootMap   
)

Definition at line 672 of file ax_fragment_root_win_unittest.cc.

672 {
673 AXNodeData root;
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}

References ui::AXFragmentRootWin::GetForAcceleratedWidget(), ui::AXFragmentRootWin::GetFragmentRootParentOf(), and ui::AXNodeData::id.

◆ TEST_F() [4/325]

ui::TEST_F ( AXFragmentRootTest  ,
TestGetChildCount   
)

Definition at line 412 of file ax_fragment_root_win_unittest.cc.

412 {
413 AXNodeData root;
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

References ui::AXPlatformNodeDelegate::GetChildCount(), and ui::AXNodeData::id.

◆ TEST_F() [5/325]

ui::TEST_F ( AXFragmentRootTest  ,
TestGetParent   
)

Definition at line 441 of file ax_fragment_root_win_unittest.cc.

441 {
442 AXNodeData root;
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

References ui::AXPlatformNodeDelegate::GetParent(), and ui::AXNodeData::id.

◆ TEST_F() [6/325]

ui::TEST_F ( AXFragmentRootTest  ,
TestGetPropertyValue   
)

Definition at line 456 of file ax_fragment_root_win_unittest.cc.

456 {
457 AXNodeData root;
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;
469 ScopedVariant result;
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}
const VARIANT * ptr() const

References ui::AXNodeData::id, base::win::ScopedVariant::ptr(), base::win::ScopedVariant::Receive(), and base::win::ScopedVariant::type().

◆ TEST_F() [7/325]

ui::TEST_F ( AXFragmentRootTest  ,
TestUIAErrorHandling   
)

Definition at line 372 of file ax_fragment_root_win_unittest.cc.

372 {
373 AXNodeData root;
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}

References ui::AXNodeData::id, and base::win::ScopedSafearray::Receive().

◆ 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}

References ui::AXNodeData::child_ids, ui::AXNode::children(), and ui::AXNodeData::id.

◆ TEST_F() [9/325]

ui::TEST_F ( AXFragmentRootTest  ,
TestUIAGetFragmentRoot   
)

Definition at line 263 of file ax_fragment_root_win_unittest.cc.

263 {
264 AXNodeData root;
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}

References ui::AXNodeData::id.

◆ 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
547 ui::AXTreeUpdate update;
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};
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}

References ui::AXNodeData::child_ids, ui::AXNode::children(), ui::AXTreeID::CreateNewAXTreeID(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ TEST_F() [11/325]

ui::TEST_F ( AXFragmentRootTest  ,
UIAFindItemByPropertyUniqueId   
)

Definition at line 45 of file ax_fragment_root_win_unittest.cc.

45 {
46 AXNodeData root;
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)
void SetName(const std::string &name)

References ui::AXNodeData::child_ids, ui::AXNode::children(), ui::MockIRawElementProviderSimple::CreateMockIRawElementProviderSimple(), EXPECT_UIA_BSTR_EQ, ui::UiaRegistrarWin::GetInstance(), ui::UiaRegistrarWin::GetUiaUniqueIdPropertyId(), ui::AXNodeData::id, ax::mojom::kButton, ax::mojom::kRootWebArea, ax::mojom::kStaticText, base::NumberToString16(), base::win::ScopedVariant::Release(), ui::AXNodeData::role, base::win::ScopedVariant::Set(), and ui::AXNodeData::SetName().

◆ TEST_F() [12/325]

ui::TEST_F ( AXPlatformNodeMacTest  ,
AccessibilityRangeForPositionDoesntCrash   
)

Definition at line 51 of file ax_platform_node_mac_unittest.mm.

51 {
52 AXNodeData root;
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

References ui::AXRelativeBounds::bounds, ui::AXPlatformNode::GetNativeViewAccessible(), ui::AXNodeData::id, and ui::AXNodeData::relative_bounds.

◆ TEST_F() [13/325]

ui::TEST_F ( AXPlatformNodeMacTest  ,
CanGetCocoaPlatformNodeFromTree   
)

Definition at line 33 of file ax_platform_node_mac_unittest.mm.

33 {
34 AXNodeData root;
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}

References ui::AXRelativeBounds::bounds, ui::AXPlatformNode::GetNativeViewAccessible(), ui::AXNodeData::id, and ui::AXNodeData::relative_bounds.

◆ 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
88 AXTreeUpdate update;
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}

References BASE_DCHECK, ui::AXNodeData::child_ids, ui::AXNode::children(), ui::AXTreeID::CreateNewAXTreeID(), base::win::ScopedBstr::Get(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kLink, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, base::win::ScopedBstr::Receive(), base::win::ScopedBstr::Release(), ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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
514 AXTreeUpdate update;
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)

References ui::AXNodeData::AddIntListAttribute(), ui::AXNodeData::AddState(), ui::AXNodeData::child_ids, ui::AXTreeID::CreateNewAXTreeID(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kGenericContainer, ax::mojom::kIgnored, ax::mojom::kLabelledbyIds, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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}

References ui::AXNodeData::child_ids, ui::AXNodeData::id, ax::mojom::kStaticText, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ 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}

References ui::AXNodeData::child_ids, ui::AXNodeData::id, ax::mojom::kParagraph, ax::mojom::kStaticText, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ 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
838 AXTreeUpdate update;
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
ax::mojom::Action action

References ui::AXActionData::action, ui::AXNodeData::child_ids, ui::AXTreeID::CreateNewAXTreeID(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kFocus, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXActionData::target_node_id, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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
898 AXTreeUpdate update;
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}

References ui::AXActionData::action, ui::AXNodeData::child_ids, ui::AXTreeID::CreateNewAXTreeID(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kFocus, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXActionData::target_node_id, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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
644 AXTreeUpdate update;
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)
size_t Length() const
void Reset(SAFEARRAY *safearray=nullptr)
long LONG

References ui::AXNodeData::AddState(), ui::AXNodeData::child_ids, ui::AXNode::children(), ui::AXTreeID::CreateNewAXTreeID(), base::win::ScopedBstr::Get(), base::win::ScopedSafearray::Get(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kEditable, ax::mojom::kGroup, ax::mojom::kInlineTextBox, ax::mojom::kStaticText, base::win::ScopedBstr::Length(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, base::win::ScopedBstr::Receive(), base::win::ScopedSafearray::Receive(), base::win::ScopedBstr::Reset(), base::win::ScopedSafearray::Reset(), ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTreeData::sel_anchor_object_id, ui::AXTreeData::sel_anchor_offset, ui::AXTreeData::sel_focus_object_id, ui::AXTreeData::sel_focus_offset, ui::AXNodeData::SetName(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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
189 AXTreeUpdate update;
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)

References BASE_DCHECK, ui::AXNodeData::child_ids, ui::AXNode::children(), ui::MockIRawElementProviderSimple::CreateMockIRawElementProviderSimple(), ui::AXTreeID::CreateNewAXTreeID(), EXPECT_INVALIDARG, EXPECT_UIA_INVALIDOPERATION, base::win::ScopedBstr::Get(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, base::win::ScopedBstr::Receive(), ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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
276 AXNodeData root;
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
317 AXTreeUpdate update;
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)

References BASE_DCHECK, ui::AXNodeData::child_ids, ui::AXNode::children(), ui::AXTreeID::CreateNewAXTreeID(), base::win::ScopedBstr::Get(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kButton, ax::mojom::kDialog, ax::mojom::kImage, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, base::win::ScopedBstr::Receive(), ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, ui::AXTreeData::tree_id, and fml::WideStringToUtf16().

◆ 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}

References ui::AXNodeData::child_ids, ui::AXNodeData::id, ax::mojom::kStaticText, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ 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}

References ui::AXNodeData::AddIntListAttribute(), ui::AXRelativeBounds::bounds, ui::AXNodeData::child_ids, ui::AXNode::children(), data, ui::AXNodeData::id, ax::mojom::kCharacterOffsets, ax::mojom::kInlineTextBox, ax::mojom::kRootWebArea, ui::AXNodeData::relative_bounds, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ 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
7300 ui::AXTreeUpdate update;
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)

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::AddState(), ui::AXNodeData::child_ids, ui::AXTreeID::CreateNewAXTreeID(), end, EXPECT_UIA_MOVE, EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT, EXPECT_UIA_TEXTATTRIBUTE_EQ, EXPECT_UIA_TEXTRANGE_EQ, ui::AXTree::GetFromId(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kEditable, ax::mojom::kGenericContainer, ax::mojom::kInlineTextBox, ax::mojom::kIsLineBreakingObject, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ax::mojom::kTextField, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, base::win::ScopedVariant::Set(), ui::AXNodeData::SetName(), ui::AXNodeData::SetValue(), start, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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
7439 ui::AXTreeUpdate update;
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)

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::AddState(), ui::AXNodeData::child_ids, ui::AXTreeID::CreateNewAXTreeID(), EXPECT_UIA_TEXTATTRIBUTE_EQ, EXPECT_UIA_TEXTRANGE_EQ, ui::AXTree::GetFromId(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kEditable, ax::mojom::kGenericContainer, ax::mojom::kImage, ax::mojom::kIsLineBreakingObject, ax::mojom::kRootWebArea, ax::mojom::kTextField, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, base::win::ScopedVariant::Reset(), ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, base::win::ScopedVariant::Set(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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
7550 ui::AXTreeUpdate update;
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}

References ui::AXNodeData::child_ids, ui::AXTreeID::CreateNewAXTreeID(), EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT, EXPECT_UIA_TEXTRANGE_EQ, ui::AXTree::GetFromId(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kGenericContainer, ax::mojom::kInlineTextBox, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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
6995 ui::AXTreeUpdate update;
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}

References ui::AXNodeData::AddState(), ui::AXNodeData::child_ids, ui::AXTreeID::CreateNewAXTreeID(), EXPECT_UIA_TEXTRANGE_EQ, ui::AXTree::GetFromId(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kGenericContainer, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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
6865 ui::AXTreeUpdate update;
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}

References ui::AXNodeData::AddState(), ui::AXNodeData::child_ids, ui::AXTreeID::CreateNewAXTreeID(), EXPECT_UIA_TEXTRANGE_EQ, ui::AXTree::GetFromId(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kGenericContainer, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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 BOOL

References EXPECT_UIA_TEXTRANGE_EQ.

◆ 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
1604 ui::AXTreeUpdate update;
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}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::AddState(), ui::AXNodeData::child_ids, ui::AXTreeID::CreateNewAXTreeID(), EXPECT_UIA_TEXTRANGE_EQ, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kButton, ax::mojom::kGenericContainer, ax::mojom::kHeading, ax::mojom::kIgnored, ax::mojom::kInlineTextBox, ax::mojom::kIsLineBreakingObject, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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}

References EXPECT_UIA_MOVE, and EXPECT_UIA_TEXTRANGE_EQ.

◆ 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
4004 ui::AXTreeUpdate update;
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)
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)

References ui::AXNodeData::AddFloatAttribute(), ui::AXNodeData::AddIntAttribute(), ui::AXNodeData::AddIntListAttribute(), ui::AXNodeData::AddState(), ui::AXNodeData::AddStringAttribute(), ui::AXNodeData::AddTextStyle(), ui::AXNodeData::child_ids, ui::AXNode::children(), ui::AXTreeID::CreateNewAXTreeID(), EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT, EXPECT_UIA_SAFEARRAY_EQ, EXPECT_UIA_TEXTATTRIBUTE_EQ, EXPECT_UIA_TEXTATTRIBUTE_MIXED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kBackgroundColor, ax::mojom::kCenter, ax::mojom::kColor, ax::mojom::kDisabled, ax::mojom::kDisc, ax::mojom::kDownstream, ax::mojom::kEditable, ax::mojom::kFontFamily, ax::mojom::kFontSize, ax::mojom::kFontWeight, ax::mojom::kGrammar, ax::mojom::kHeading, ax::mojom::kHierarchicalLevel, ax::mojom::kHtmlTag, ax::mojom::kInputType, ax::mojom::kInvisible, ax::mojom::kItalic, ax::mojom::kJustify, ax::mojom::kLanguage, ax::mojom::kLink, ax::mojom::kList, ax::mojom::kListItem, ax::mojom::kListStyle, ax::mojom::kMark, ax::mojom::kMarkerEnds, ax::mojom::kMarkerStarts, ax::mojom::kMarkerTypes, ax::mojom::kNameFrom, ax::mojom::kNone, ax::mojom::kOther, ax::mojom::kPlaceholder, ax::mojom::kReadOnly, ax::mojom::kRootWebArea, ax::mojom::kRtl, ax::mojom::kSpelling, ax::mojom::kStaticText, ax::mojom::kSubscript, ax::mojom::kSuperscript, ax::mojom::kTextField, ax::mojom::kTextOverlineStyle, ax::mojom::kTextStrikethroughStyle, ax::mojom::kTextUnderlineStyle, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, base::win::ScopedVariant::ptr(), base::win::ScopedVariant::Receive(), base::win::ScopedVariant::Reset(), ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, base::win::ScopedVariant::Set(), ui::AXNodeData::SetName(), ui::AXNodeData::SetRestriction(), ui::AXNodeData::SetTextAlign(), ui::AXNodeData::SetTextDirection(), ui::AXNodeData::SetTextPosition(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, ui::AXTreeData::tree_id, and base::win::ScopedVariant::type().

◆ 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
4461 AXNodeData root;
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
4516 ui::AXTreeUpdate update;
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};
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)

References ui::AXNodeData::AddIntListAttribute(), ui::AXNodeData::child_ids, ui::AXNode::children(), ui::AXTreeID::CreateNewAXTreeID(), EXPECT_UIA_ELEMENT_ARRAY_BSTR_EQ, EXPECT_UIA_TEXTRANGE_EQ, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kComment, ax::mojom::kDetailsIds, ax::mojom::kDownstream, ax::mojom::kMark, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, base::win::ScopedVariant::ptr(), base::win::ScopedVariant::Receive(), ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, ui::AXTreeData::tree_id, and base::win::ScopedVariant::type().

◆ 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
4610 AXNodeData root;
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
4647 ui::AXTreeUpdate update;
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};
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}

References ui::AXNodeData::AddIntListAttribute(), ui::AXNodeData::child_ids, ui::AXNode::children(), ui::AXTreeID::CreateNewAXTreeID(), EXPECT_UIA_ELEMENT_ARRAY_BSTR_EQ, EXPECT_UIA_TEXTATTRIBUTE_EQ, EXPECT_UIA_TEXTATTRIBUTE_MIXED, EXPECT_UIA_TEXTRANGE_EQ, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kComment, ax::mojom::kDetailsIds, ax::mojom::kDownstream, ax::mojom::kMark, ax::mojom::kReadOnly, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, base::win::ScopedVariant::ptr(), base::win::ScopedVariant::Receive(), base::win::ScopedVariant::Reset(), ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, base::win::ScopedVariant::Set(), ui::AXNodeData::SetName(), ui::AXNodeData::SetRestriction(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, ui::AXTreeData::tree_id, and base::win::ScopedVariant::type().

◆ 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}

References EXPECT_UIA_SAFEARRAY_EQ, base::win::ScopedSafearray::Get(), base::win::ScopedSafearray::Receive(), and base::win::ScopedSafearray::Reset().

◆ 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
1744 ui::AXTreeUpdate update;
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}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::child_ids, ui::AXTreeID::CreateNewAXTreeID(), EXPECT_UIA_TEXTRANGE_EQ, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kGenericContainer, ax::mojom::kInlineTextBox, ax::mojom::kIsLineBreakingObject, ax::mojom::kRootWebArea, ax::mojom::kSplitter, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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)

References ui::AXTreeID::CreateNewAXTreeID(), EXPECT_ENCLOSING_ELEMENT, EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT, EXPECT_UIA_TEXTRANGE_EQ, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ax::mojom::kButton, ax::mojom::kEditable, ax::mojom::kGenericContainer, ax::mojom::kIgnored, ax::mojom::kRichlyEditable, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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}

References ui::MockAXPlatformNodeTextRangeProviderWin::CreateMockTextRangeProvider(), EXPECT_UIA_ELEMENTNOTAVAILABLE, and EXPECT_UIA_INVALIDOPERATION.

◆ 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}

References EXPECT_UIA_MOVE, and EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT.

◆ 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)

References EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT, EXPECT_UIA_TEXTRANGE_EQ, and base::UTF16ToUTF8().

◆ 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}

References EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT, and EXPECT_UIA_TEXTRANGE_EQ.

◆ 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}

References EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT, and EXPECT_UIA_TEXTRANGE_EQ.

◆ 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
2951 ui::AXTreeUpdate update;
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()

References ui::AXNodeData::AddIntListAttribute(), ui::AXNodeData::AddState(), ui::AXNodeData::AddStringAttribute(), ui::AXNodeData::child_ids, ui::AXNode::children(), ui::AXTreeID::CreateNewAXTreeID(), EXPECT_UIA_TEXTRANGE_EQ, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kEditable, ax::mojom::kGenericContainer, ax::mojom::kHtmlTag, ax::mojom::kInputType, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ax::mojom::kTextField, ax::mojom::kWordEnds, ax::mojom::kWordStarts, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXNodeData::SetNameExplicitlyEmpty(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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}

References EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT, and EXPECT_UIA_TEXTRANGE_EQ.

◆ 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}

References EXPECT_UIA_MOVE, and EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT.

◆ 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}

References EXPECT_UIA_MOVE, and EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT.

◆ 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}

References EXPECT_UIA_MOVE, and EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT.

◆ 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}

References EXPECT_UIA_MOVE, and EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT.

◆ 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
6341 ui::AXTreeUpdate update;
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}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::AddState(), ui::AXNodeData::child_ids, ui::AXTreeID::CreateNewAXTreeID(), ui::AXTree::GetFromId(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kEditable, ax::mojom::kGenericContainer, ax::mojom::kInlineTextBox, ax::mojom::kIsLineBreakingObject, ax::mojom::kLineBreak, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ax::mojom::kTextField, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXNodeData::SetValue(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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
6415 ui::AXTreeUpdate update;
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}

References ui::AXNodeData::child_ids, ui::AXTreeID::CreateNewAXTreeID(), EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT, ui::AXTree::GetFromId(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXNodeData::SetNameExplicitlyEmpty(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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}

References ui::AXNodeData::id, ax::mojom::kRootWebArea, and ui::AXNodeData::role.

◆ 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
5232 ui::AXTreeUpdate update;
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
5247 base::win::ScopedBstr find_string(L"oobar");
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}

References ui::AXNodeData::child_ids, ui::AXTreeID::CreateNewAXTreeID(), base::win::ScopedBstr::Get(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kInlineTextBox, ax::mojom::kList, ax::mojom::kListItem, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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
6732 ui::AXTreeUpdate update;
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}

References ui::AXNodeData::child_ids, ui::AXTreeID::CreateNewAXTreeID(), EXPECT_UIA_TEXTRANGE_EQ, ui::AXTree::GetFromId(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kGenericContainer, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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
7097 ui::AXTreeUpdate update;
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}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::child_ids, ui::AXTreeID::CreateNewAXTreeID(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), EXPECT_UIA_TEXTRANGE_EQ, ui::AXTree::GetAXTreeID(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kButton, ax::mojom::kGenericContainer, ax::mojom::kHeading, ax::mojom::kInlineTextBox, ax::mojom::kIsLineBreakingObject, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, ui::AXTreeData::tree_id, and ui::AXTree::Unserialize().

◆ 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}

References EXPECT_UIA_TEXTRANGE_EQ.

◆ 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));
3124 EXPECT_TRUE(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}

References ui::AXNode::children().

◆ 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}

References ui::AXNode::children().

◆ 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}

References ui::AXNode::children(), and EXPECT_UIA_TEXTRANGE_EQ.

◆ 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}

References ui::AXNode::children(), and EXPECT_UIA_TEXTRANGE_EQ.

◆ 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}

References EXPECT_UIA_TEXTRANGE_EQ.

◆ 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}

References EXPECT_UIA_TEXTRANGE_EQ.

◆ 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
5330 ui::AXTreeUpdate update;
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
5419 ui::AXTreeUpdate update;
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
5508 ui::AXTreeUpdate update;
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
5617 ui::AXTreeUpdate update;
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
5735 ui::AXTreeUpdate update;
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}

References ui::AXNodeData::AddState(), ui::AXNodeData::child_ids, ui::AXTreeID::CreateNewAXTreeID(), EXPECT_UIA_TEXTRANGE_EQ, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kInvisible, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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]);
5162 base::win::ScopedBstr find_string(L"more text");
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)
void InitializeICU(const std::string &icu_data_path)
Definition icu_util.cc:102
#define MAX_PATH

References ui::AXNode::children(), EXPECT_UIA_FIND_TEXT, EXPECT_UIA_FIND_TEXT_NO_MATCH, base::win::ScopedBstr::Get(), fml::icu::InitializeICU(), and 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;
5279 base::win::ScopedBstr find_string(L"text");
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}

References ui::AXNode::children(), EXPECT_UIA_TEXTRANGE_EQ, and base::win::ScopedBstr::Get().

◆ 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
4751 ui::AXTreeUpdate update;
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)

References ui::AXNodeData::child_ids, ui::AXTreeID::CreateNewAXTreeID(), EXPECT_UIA_TEXTATTRIBUTE_NOTSUPPORTED, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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}

References ui::AXTreeID::CreateNewAXTreeID(), EXPECT_UIA_TEXTATTRIBUTE_EQ, ui::AXTree::GetFromId(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ax::mojom::kBackgroundColor, ax::mojom::kDownstream, ax::mojom::kGenericContainer, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, base::win::ScopedVariant::Set(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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
3328 ui::AXTreeUpdate update;
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}

References ui::AXNodeData::AddState(), ui::AXNodeData::AddStringAttribute(), ui::AXNodeData::child_ids, ui::AXNode::children(), ui::AXTreeID::CreateNewAXTreeID(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kEditable, ax::mojom::kHtmlTag, ax::mojom::kInlineTextBox, ax::mojom::kInputType, ax::mojom::kLink, ax::mojom::kList, ax::mojom::kListItem, ax::mojom::kParagraph, ax::mojom::kPdfActionableHighlight, ax::mojom::kRootWebArea, ax::mojom::kSearchBox, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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
3471 ui::AXNodeData root;
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
3511 ui::AXTreeUpdate update;
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}

References ui::AXNodeData::child_ids, ui::AXNode::children(), ui::AXTreeID::CreateNewAXTreeID(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kButton, ax::mojom::kHeading, ax::mojom::kInlineTextBox, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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}

References ui::AXNode::children(), base::win::ScopedBstr::Get(), base::win::ScopedBstr::Receive(), and base::win::ScopedBstr::Reset().

◆ 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}

References EXPECT_UIA_MOVE, and EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT.

◆ 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}

References ui::AXNode::children(), and EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT.

◆ 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}

References ui::AXNode::children().

◆ 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}

References ui::AXNode::OwnerTree::Selection::anchor_object_id, ui::AXNode::OwnerTree::Selection::anchor_offset, ui::AXNode::children(), EXPECT_UIA_TEXTRANGE_EQ, ui::AXNode::OwnerTree::Selection::focus_object_id, ui::AXNode::OwnerTree::Selection::focus_offset, base::win::ScopedSafearray::Get(), ui::AXPlatformNodeDelegate::GetUnignoredSelection(), base::win::ScopedSafearray::Receive(), and base::win::ScopedSafearray::Reset().

◆ 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}

References ASSERT_UIA_INVALIDOPERATION.

◆ 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
5075 ui::AXTreeUpdate update;
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}

References ui::AXNodeData::child_ids, ui::AXNode::children(), ui::AXTreeID::CreateNewAXTreeID(), base::win::ScopedSafearray::Get(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kList, ax::mojom::kListItem, ax::mojom::kListMarker, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, base::win::ScopedSafearray::Receive(), base::win::ScopedSafearray::Reset(), ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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.
6172 AXTreeUpdate update;
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}

References ui::AXTreeID::CreateNewAXTreeID(), ui::AXTree::GetFromId(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ax::mojom::kDownstream, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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
6017 AXTreeUpdate update;
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}

References ui::AXTreeID::CreateNewAXTreeID(), EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT, EXPECT_UIA_TEXTRANGE_EQ, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ax::mojom::kInlineTextBox, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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
6086 AXTreeUpdate update;
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}

References ui::AXTreeID::CreateNewAXTreeID(), EXPECT_UIA_MOVE_ENDPOINT_BY_UNIT, EXPECT_UIA_TEXTRANGE_EQ, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ax::mojom::kIgnored, ax::mojom::kInlineTextBox, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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
6227 ui::AXTreeUpdate update;
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}

References ui::AXNodeData::AddState(), ui::AXNodeData::child_ids, ui::AXTreeID::CreateNewAXTreeID(), ui::AXTree::GetFromId(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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
6570 ui::AXTreeUpdate update;
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}

References ui::AXNodeData::AddState(), ui::AXNodeData::child_ids, ui::AXTreeID::CreateNewAXTreeID(), EXPECT_UIA_TEXTRANGE_EQ, ui::AXTree::GetFromId(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kGroup, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, base::win::ScopedSafearray::Receive(), ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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
7171 ui::AXTreeUpdate update;
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}

References ui::AXNodeData::AddState(), ui::AXNodeData::child_ids, ui::AXTreeID::CreateNewAXTreeID(), EXPECT_UIA_TEXTRANGE_EQ, ui::AXTree::GetFromId(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kGroup, ax::mojom::kIgnored, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ TEST_F() [84/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
AccNavigate   
)

Definition at line 1069 of file ax_platform_node_win_unittest.cc.

1069 {
1070 AXNodeData root;
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}
static const VARIANT kEmptyVariant
VARIANT * AsInput() const

References base::win::ScopedVariant::AsInput(), ui::AXNodeData::child_ids, end, ui::AXNodeData::id, ax::mojom::kRootWebArea, ax::mojom::kStaticText, base::win::ScopedVariant::ptr(), and ui::AXNodeData::role.

◆ 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}
const char * name
Definition fuchsia.cc:49

References ax::mojom::kAnnotationAdult, ax::mojom::kAnnotationEmpty, ax::mojom::kAnnotationPending, ax::mojom::kAnnotationProcessFailed, ax::mojom::kAnnotationSucceeded, ax::mojom::kEligibleForAnnotation, ax::mojom::kImage, ax::mojom::kImageAnnotation, ax::mojom::kIneligibleForAnnotation, ax::mojom::kSilentlyEligibleForAnnotation, name, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ TEST_F() [86/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ComputeUIAControlType   
)

Definition at line 3034 of file ax_platform_node_win_unittest.cc.

3034 {
3035 AXNodeData root;
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

References ui::AXNodeData::child_ids, EXPECT_UIA_INT_EQ, ui::AXNodeData::id, ax::mojom::kLayoutTable, ax::mojom::kRootWebArea, ax::mojom::kSearchBox, ax::mojom::kTable, ax::mojom::kTextField, and ui::AXNodeData::role.

◆ TEST_F() [87/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
GetPatternProviderExpandCollapsePattern   
)

Definition at line 3578 of file ax_platform_node_win_unittest.cc.

3578 {
3579 ui::AXNodeData root;
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}

References ui::AXNodeData::AddState(), ui::AXNodeData::child_ids, ui::AXNodeData::id, ax::mojom::kCollapsed, ax::mojom::kComboBoxGrouping, ax::mojom::kComboBoxMenuButton, ax::mojom::kDisclosureTriangle, ax::mojom::kExpanded, ax::mojom::kFalse, ax::mojom::kListBoxOption, ax::mojom::kListItem, ax::mojom::kMenuItem, ax::mojom::kMenuListOption, ax::mojom::kTextFieldWithComboBox, ax::mojom::kTreeItem, ax::mojom::kTrue, ui::AXNodeData::role, and ui::AXNodeData::SetHasPopup().

◆ TEST_F() [88/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
GetPatternProviderInvokePattern   
)

Definition at line 3696 of file ax_platform_node_win_unittest.cc.

3696 {
3697 ui::AXNodeData root;
3698 root.id = 1;
3699
3700 ui::AXNodeData link;
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}

References ui::AXNodeData::child_ids, ui::AXNodeData::id, ax::mojom::kCheckBox, ax::mojom::kComboBoxGrouping, ax::mojom::kGenericContainer, ax::mojom::kLink, and ui::AXNodeData::role.

◆ 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
3439 AXTreeUpdate update;
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}

References ui::AXTreeID::CreateNewAXTreeID(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ax::mojom::kCell, ax::mojom::kCheckBox, ax::mojom::kColumnHeader, ax::mojom::kGrid, ax::mojom::kGroup, ax::mojom::kLink, ax::mojom::kMeter, ax::mojom::kRootWebArea, ax::mojom::kRow, ax::mojom::kScrollX, ax::mojom::kScrollXMax, ax::mojom::kScrollXMin, ax::mojom::kSelected, ax::mojom::kTable, ax::mojom::kTextFieldWithComboBox, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ TEST_F() [90/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
GetPropertyValue_HelpText   
)

Definition at line 2355 of file ax_platform_node_win_unittest.cc.

2355 {
2356 AXNodeData root;
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)

References ui::AXNodeData::AddIntAttribute(), ui::AXNodeData::AddStringAttribute(), ui::AXNodeData::child_ids, EXPECT_UIA_BSTR_EQ, EXPECT_UIA_VALUE_EQ, ui::AXNodeData::id, ax::mojom::kAttribute, ax::mojom::kNameFrom, ax::mojom::kPlaceholder, ax::mojom::kRootWebArea, ax::mojom::kTextField, ax::mojom::kTitle, ax::mojom::kTooltip, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ TEST_F() [91/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
GetPropertyValue_IsControlElement   
)

Definition at line 2463 of file ax_platform_node_win_unittest.cc.

2463 {
2464 AXTreeUpdate update;
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;
2500 update.nodes[11].role = ax::mojom::Role::kGenericContainer;
2501 update.nodes[11].AddBoolAttribute(ax::mojom::BoolAttribute::kHasAriaAttribute,
2502 true);
2503 update.nodes[12].id = 13;
2504 update.nodes[12].role = ax::mojom::Role::kGenericContainer;
2505 update.nodes[12].AddBoolAttribute(ax::mojom::BoolAttribute::kEditableRoot,
2506 true);
2507 update.nodes[13].id = 14;
2508 update.nodes[13].role = ax::mojom::Role::kGenericContainer;
2509 update.nodes[13].SetName("name");
2510 update.nodes[14].id = 15;
2511 update.nodes[14].role = ax::mojom::Role::kGenericContainer;
2512 update.nodes[14].SetDescription("description");
2513 update.nodes[15].id = 16;
2514 update.nodes[15].role = ax::mojom::Role::kGenericContainer;
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)

References ui::AXTreeID::CreateNewAXTreeID(), EXPECT_UIA_BOOL_EQ, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ax::mojom::kArticle, ax::mojom::kButton, ax::mojom::kEditableRoot, ax::mojom::kFocusable, ax::mojom::kForm, ax::mojom::kGenericContainer, ax::mojom::kHasAriaAttribute, ax::mojom::kImage, ax::mojom::kList, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ax::mojom::kTable, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::TestAXNodeWrapper::SetGlobalIsWebContent(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ 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}

References ui::AXNodeData::AddIntListAttribute(), ui::AXNodeData::child_ids, ui::AXNode::children(), EXPECT_UIA_BSTR_EQ, ui::AXNode::OwnerTree::GetAXTreeID(), ui::TestAXNodeWrapper::GetOrCreate(), ui::AXNode::id(), ui::AXNodeData::id, ax::mojom::kAlert, ax::mojom::kGenericContainer, ax::mojom::kLabelledbyIds, ax::mojom::kRootWebArea, ax::mojom::kStaticText, base::win::ScopedVariant::ptr(), base::win::ScopedVariant::Receive(), base::win::ScopedVariant::Reset(), ui::TestAXNodeWrapper::ResetNativeEventTarget(), ui::AXNodeData::role, ui::AXNodeData::SetName(), ui::AXNode::tree(), and base::win::ScopedVariant::type().

◆ TEST_F() [93/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
GetPropertyValue_LocalizedControlType   
)

Definition at line 2429 of file ax_platform_node_win_unittest.cc.

2429 {
2430 AXNodeData root;
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}

References ui::AXNodeData::AddStringAttribute(), ui::AXNodeData::child_ids, EXPECT_UIA_BSTR_EQ, ui::AXNodeData::id, ax::mojom::kRoleDescription, ax::mojom::kSearchBox, ax::mojom::kUnknown, and ui::AXNodeData::role.

◆ TEST_F() [94/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleAccValue   
)

Definition at line 556 of file ax_platform_node_win_unittest.cc.

556 {
557 AXNodeData root;
558 root.id = 1;
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);
570 ScopedBstr v2;
571 EXPECT_EQ(E_INVALIDARG, root_obj->get_accValue(bad_id, v2.Receive()));
572}

References ui::AXNodeData::AddStringAttribute(), ui::AXNodeData::id, ax::mojom::kTextField, ax::mojom::kValue, base::win::ScopedBstr::Receive(), ui::AXNodeData::role, and value.

◆ TEST_F() [95/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleChildAndParent   
)

Definition at line 994 of file ax_platform_node_win_unittest.cc.

994 {
995 AXNodeData root;
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}

References ui::AXNodeData::child_ids, ui::AXNode::children(), ui::AXNodeData::id, ax::mojom::kButton, ax::mojom::kCheckBox, and ui::AXNodeData::role.

◆ TEST_F() [96/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleDescription   
)

Definition at line 538 of file ax_platform_node_win_unittest.cc.

538 {
539 AXNodeData root;
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}

References ui::AXNodeData::AddStringAttribute(), base::win::ScopedBstr::Get(), ui::AXNodeData::id, ax::mojom::kDescription, and base::win::ScopedBstr::Receive().

◆ TEST_F() [97/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleDetachedObject   
)

Definition at line 432 of file ax_platform_node_win_unittest.cc.

432 {
433 AXNodeData root;
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}

References ui::AXNodeData::id, ax::mojom::kRootWebArea, name, base::win::ScopedBstr::Receive(), ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ TEST_F() [98/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleHitTest   
)

Definition at line 450 of file ax_platform_node_win_unittest.cc.

450 {
451 AXNodeData root;
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}

References ui::AXRelativeBounds::bounds, ui::AXNodeData::child_ids, ui::AXNodeData::id, ax::mojom::kGenericContainer, base::win::ScopedVariant::ptr(), base::win::ScopedVariant::Receive(), ui::AXNodeData::relative_bounds, ui::AXNodeData::role, ui::AXNodeData::SetName(), ui::TestAXNodeWrapper::SetScaleFactor(), and base::win::ScopedVariant::type().

◆ TEST_F() [99/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleHitTestDoesNotLoopForever   
)

Definition at line 492 of file ax_platform_node_win_unittest.cc.

492 {
493 AXNodeData root;
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}

References ui::AXRelativeBounds::bounds, ui::AXNodeData::child_ids, ui::AXNodeData::id, ax::mojom::kGenericContainer, base::win::ScopedVariant::ptr(), base::win::ScopedVariant::Receive(), ui::AXNodeData::relative_bounds, ui::AXNodeData::role, ui::TestAXNodeWrapper::SetHitTestResult(), and ui::AXNodeData::SetName().

◆ TEST_F() [100/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleLocation   
)

Definition at line 962 of file ax_platform_node_win_unittest.cc.

962 {
963 AXNodeData root;
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

References ui::AXRelativeBounds::bounds, height, ui::AXNodeData::id, ui::AXNodeData::relative_bounds, ui::TestAXNodeWrapper::SetGlobalCoordinateOffset(), and width.

◆ TEST_F() [101/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleName   
)

Definition at line 520 of file ax_platform_node_win_unittest.cc.

520 {
521 AXNodeData root;
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}

References ui::AXNodeData::id, ax::mojom::kRootWebArea, name, base::win::ScopedBstr::Receive(), ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ TEST_F() [102/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleRole   
)

Definition at line 927 of file ax_platform_node_win_unittest.cc.

927 {
928 AXNodeData root;
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

References ui::AXNodeData::child_ids, ui::AXNode::children(), ui::AXNodeData::id, ax::mojom::kAlert, ax::mojom::kButton, ax::mojom::kPopUpButton, base::win::ScopedVariant::ptr(), base::win::ScopedVariant::Receive(), ui::AXNodeData::role, and ui::AXNode::SetData().

◆ 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

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::child_ids, ui::AXNodeData::id, ax::mojom::kListBox, ax::mojom::kListBoxOption, ax::mojom::kSelected, name, base::win::ScopedVariant::ptr(), base::win::ScopedVariant::Receive(), ui::AXNodeData::role, ui::AXNodeData::SetName(), and base::win::ScopedVariant::type().

◆ 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}

References ui::AXNodeData::child_ids, ui::AXNodeData::id, ax::mojom::kListBox, ax::mojom::kListBoxOption, base::win::ScopedVariant::Receive(), ui::AXNodeData::role, ui::AXNodeData::SetName(), and base::win::ScopedVariant::type().

◆ 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}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::child_ids, ui::AXNodeData::id, ax::mojom::kListBox, ax::mojom::kListBoxOption, ax::mojom::kSelected, base::win::ScopedVariant::Receive(), ui::AXNodeData::role, ui::AXNodeData::SetName(), and base::win::ScopedVariant::type().

◆ 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}

References ax::mojom::kSelected, name, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, base::win::ScopedVariant::ptr(), base::win::ScopedVariant::Receive(), and base::win::ScopedVariant::type().

◆ 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}

References ax::mojom::kSelected, name, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, base::win::ScopedVariant::ptr(), base::win::ScopedVariant::Receive(), and base::win::ScopedVariant::type().

◆ 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}

References base::win::ScopedVariant::Receive(), and base::win::ScopedVariant::type().

◆ 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}

References ax::mojom::kSelected, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, base::win::ScopedVariant::ptr(), base::win::ScopedVariant::Receive(), and base::win::ScopedVariant::type().

◆ 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}

References ax::mojom::kSelected, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, base::win::ScopedVariant::ptr(), base::win::ScopedVariant::Receive(), and base::win::ScopedVariant::type().

◆ TEST_F() [111/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IAccessibleShortcut   
)

Definition at line 574 of file ax_platform_node_win_unittest.cc.

574 {
575 AXNodeData root;
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}

References ui::AXNodeData::AddStringAttribute(), base::win::ScopedBstr::Get(), ui::AXNodeData::id, ax::mojom::kKeyShortcuts, and base::win::ScopedBstr::Receive().

◆ TEST_F() [112/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IExpandCollapsePatternProviderAction   
)

Definition at line 3762 of file ax_platform_node_win_unittest.cc.

3762 {
3763 ui::AXNodeData root;
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}

References ui::AXNodeData::AddState(), ui::AXNodeData::child_ids, ui::AXNodeData::id, ax::mojom::kButton, ax::mojom::kCollapsed, ax::mojom::kComboBoxGrouping, ax::mojom::kDisabled, ax::mojom::kExpanded, ax::mojom::kGenericContainer, ax::mojom::kMenu, ax::mojom::kTrue, ui::AXNodeData::role, ui::AXNodeData::SetCheckedState(), ui::AXNodeData::SetHasPopup(), and ui::AXNodeData::SetRestriction().

◆ 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 {
1379 AXNodeData root;
1380 root.id = 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}

References ui::AXNodeData::AddIntAttribute(), ui::AXNodeData::child_ids, ui::AXNodeData::id, ax::mojom::kAriaColumnCount, ax::mojom::kAriaRowCount, ax::mojom::kCell, ax::mojom::kGrid, ax::mojom::kRow, and ui::AXNodeData::role.

◆ 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 {
3932 ui::AXNodeData root;
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)

References ui::AXNodeData::child_ids, ui::AXNode::children(), EXPECT_UIA_ELEMENTNOTENABLED, ui::TestAXNodeWrapper::GetNodeFromLastDefaultAction(), ui::AXNodeData::id, ax::mojom::kButton, ax::mojom::kDisabled, ui::AXNodeData::role, and ui::AXNodeData::SetRestriction().

◆ 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}

References ui::AXNodeData::child_ids, ui::AXNode::children(), ui::TestAXNodeWrapper::GetNodeFromLastShowContextMenu(), and ui::AXNodeData::id.

◆ TEST_F() [118/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IScrollProviderSetScrollPercent   
)

Definition at line 4607 of file ax_platform_node_win_unittest.cc.

4607 {
4608 AXNodeData root;
4609 root.id = 1;
4614
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}

References ui::AXNodeData::AddIntAttribute(), ui::AXNodeData::id, ax::mojom::kGenericContainer, ax::mojom::kScrollX, ax::mojom::kScrollXMax, ax::mojom::kScrollXMin, ax::mojom::kScrollY, ax::mojom::kScrollYMax, ax::mojom::kScrollYMin, and ui::AXNodeData::role.

◆ TEST_F() [119/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionItemProviderDisabled   
)

Definition at line 3987 of file ax_platform_node_win_unittest.cc.

3987 {
3988 AXNodeData root;
3989 root.id = 1;
3991 static_cast<int>(ax::mojom::Restriction::kDisabled));
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}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::AddIntAttribute(), EXPECT_UIA_ELEMENTNOTENABLED, ui::AXNodeData::id, ax::mojom::kDisabled, ax::mojom::kRestriction, ax::mojom::kSelected, ax::mojom::kTab, and ui::AXNodeData::role.

◆ TEST_F() [120/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionItemProviderGetSelectionContainer   
)

Definition at line 4356 of file ax_platform_node_win_unittest.cc.

4356 {
4357 AXNodeData root;
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}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::child_ids, ui::AXNodeData::id, ax::mojom::kCell, ax::mojom::kGrid, ax::mojom::kRow, ax::mojom::kSelected, and ui::AXNodeData::role.

◆ TEST_F() [121/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionItemProviderGrid   
)

Definition at line 4289 of file ax_platform_node_win_unittest.cc.

4289 {
4290 AXNodeData root;
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}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::child_ids, ui::AXNodeData::id, ax::mojom::kCell, ax::mojom::kGrid, ax::mojom::kRow, ax::mojom::kSelected, and ui::AXNodeData::role.

◆ TEST_F() [122/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionItemProviderMenuItemRadio   
)

Definition at line 4176 of file ax_platform_node_win_unittest.cc.

4176 {
4177 AXNodeData root;
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}

References ui::AXNodeData::AddIntAttribute(), ui::AXNodeData::child_ids, ui::AXNodeData::id, ax::mojom::kCheckedState, ax::mojom::kFalse, ax::mojom::kMenu, ax::mojom::kMenuItemRadio, ax::mojom::kMixed, ax::mojom::kNone, ax::mojom::kTrue, and ui::AXNodeData::role.

◆ TEST_F() [123/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionItemProviderNotSelectable   
)

Definition at line 4013 of file ax_platform_node_win_unittest.cc.

4013 {
4014 AXNodeData root;
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}

References ui::AXNodeData::id, ax::mojom::kTab, and ui::AXNodeData::role.

◆ TEST_F() [124/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionItemProviderNotSupported   
)

Definition at line 3972 of file ax_platform_node_win_unittest.cc.

3972 {
3973 AXNodeData root;
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}

References ui::AXNodeData::id, ax::mojom::kNone, and ui::AXNodeData::role.

◆ TEST_F() [125/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionItemProviderRadioButton   
)

Definition at line 4088 of file ax_platform_node_win_unittest.cc.

4088 {
4089 AXNodeData root;
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}

References ui::AXNodeData::AddIntAttribute(), ui::AXNodeData::child_ids, ui::AXNodeData::id, ax::mojom::kCheckedState, ax::mojom::kFalse, ax::mojom::kMixed, ax::mojom::kNone, ax::mojom::kRadioButton, ax::mojom::kRadioGroup, ax::mojom::kTrue, and ui::AXNodeData::role.

◆ TEST_F() [126/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionItemProviderSelectFollowFocus   
)

Definition at line 4387 of file ax_platform_node_win_unittest.cc.

4387 {
4388 AXNodeData root;
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
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}
static gboolean is_selected(FlutterSemanticsFlags flags)

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::child_ids, ui::TestAXNodeWrapper::GetNodeFromLastDefaultAction(), ui::AXNodeData::id, is_selected(), ax::mojom::kClick, ax::mojom::kSelected, ax::mojom::kTab, ax::mojom::kTabList, ui::AXNodeData::role, ui::AXNodeData::SetDefaultActionVerb(), and ui::TestAXNodeWrapper::SetNodeFromLastDefaultAction().

◆ TEST_F() [127/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionItemProviderSimple   
)

Definition at line 4028 of file ax_platform_node_win_unittest.cc.

4028 {
4029 AXNodeData root;
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}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::child_ids, ui::AXNodeData::id, ax::mojom::kListBox, ax::mojom::kListBoxOption, ax::mojom::kSelected, and ui::AXNodeData::role.

◆ TEST_F() [128/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ISelectionItemProviderTable   
)

Definition at line 4264 of file ax_platform_node_win_unittest.cc.

4264 {
4265 AXNodeData root;
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}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::child_ids, ui::AXNodeData::id, ax::mojom::kCell, ax::mojom::kRow, ax::mojom::kSelected, ax::mojom::kTable, and ui::AXNodeData::role.

◆ 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}
return TRUE

References TRUE.

◆ 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}

References ax::mojom::kFocusable, and ax::mojom::kMultiselectable.

◆ 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}

References base::win::ScopedSafearray::Get(), ax::mojom::kFocusable, ax::mojom::kMultiselectable, and base::win::ScopedSafearray::Receive().

◆ 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}

References base::win::ScopedSafearray::Get(), ax::mojom::kFocusable, and base::win::ScopedSafearray::Receive().

◆ 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}

References base::win::ScopedSafearray::Get(), ax::mojom::kFocusable, and base::win::ScopedSafearray::Receive().

◆ 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}

References TRUE.

◆ 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}

References ax::mojom::kRequired.

◆ TEST_F() [136/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ITableItemProviderGetColumnHeaderItems   
)

Definition at line 1638 of file ax_platform_node_win_unittest.cc.

1638 {
1639 AXNodeData root;
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)

References ui::TestAXNodeWrapper::BuildAllWrappers(), ui::AXNodeData::child_ids, EXPECT_UIA_ELEMENT_ARRAY_BSTR_EQ, base::win::ScopedSafearray::Get(), ui::TestAXNodeWrapper::GetOrCreate(), ui::AXNodeData::id, ax::mojom::kCell, ax::mojom::kColumnHeader, ax::mojom::kRow, ax::mojom::kTable, base::win::ScopedSafearray::Receive(), base::win::ScopedSafearray::Release(), ui::TestAXNodeWrapper::ResetNativeEventTarget(), ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ TEST_F() [137/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ITableItemProviderGetRowHeaderItems   
)

Definition at line 1701 of file ax_platform_node_win_unittest.cc.

1701 {
1702 AXNodeData root;
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}

References ui::TestAXNodeWrapper::BuildAllWrappers(), ui::AXNodeData::child_ids, EXPECT_UIA_ELEMENT_ARRAY_BSTR_EQ, base::win::ScopedSafearray::Get(), ui::TestAXNodeWrapper::GetOrCreate(), ui::AXNodeData::id, ax::mojom::kCell, ax::mojom::kRow, ax::mojom::kRowHeader, ax::mojom::kTable, base::win::ScopedSafearray::Receive(), base::win::ScopedSafearray::Release(), ui::TestAXNodeWrapper::ResetNativeEventTarget(), ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ TEST_F() [138/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ITableProviderGetColumnHeaders   
)

Definition at line 1410 of file ax_platform_node_win_unittest.cc.

1410 {
1411 AXNodeData root;
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}

References ui::AXNodeData::child_ids, EXPECT_UIA_ELEMENT_ARRAY_BSTR_EQ, base::win::ScopedSafearray::Get(), ui::TestAXNodeWrapper::GetOrCreate(), ui::AXNodeData::id, ax::mojom::kColumnHeader, ax::mojom::kRow, ax::mojom::kRowHeader, ax::mojom::kTable, base::win::ScopedSafearray::Receive(), base::win::ScopedSafearray::Release(), ui::TestAXNodeWrapper::ResetNativeEventTarget(), ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ 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
1481 AXNodeData root;
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}

References ui::AXNodeData::child_ids, EXPECT_UIA_ELEMENT_ARRAY_BSTR_EQ, base::win::ScopedSafearray::Get(), ui::AXNodeData::id, ax::mojom::kCell, ax::mojom::kColumnHeader, ax::mojom::kRow, ax::mojom::kTable, base::win::ScopedSafearray::Receive(), ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ TEST_F() [140/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ITableProviderGetRowHeaders   
)

Definition at line 1576 of file ax_platform_node_win_unittest.cc.

1576 {
1577 AXNodeData root;
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}

References ui::AXNodeData::child_ids, EXPECT_UIA_ELEMENT_ARRAY_BSTR_EQ, base::win::ScopedSafearray::Get(), ui::TestAXNodeWrapper::GetOrCreate(), ui::AXNodeData::id, ax::mojom::kColumnHeader, ax::mojom::kRow, ax::mojom::kRowHeader, ax::mojom::kTable, base::win::ScopedSafearray::Receive(), base::win::ScopedSafearray::Release(), ui::TestAXNodeWrapper::ResetNativeEventTarget(), ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ TEST_F() [141/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
ITableProviderGetRowOrColumnMajor   
)

Definition at line 1622 of file ax_platform_node_win_unittest.cc.

1622 {
1623 AXNodeData root;
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}

References ui::AXNodeData::id, ax::mojom::kTable, and ui::AXNodeData::role.

◆ TEST_F() [142/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IValueProvider_GetValue   
)

Definition at line 4446 of file ax_platform_node_win_unittest.cc.

4446 {
4447 AXNodeData root;
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}

References ui::AXNodeData::AddFloatAttribute(), ui::AXNodeData::AddIntAttribute(), ui::AXNodeData::AddState(), ui::AXNodeData::AddStringAttribute(), ui::AXNodeData::child_ids, base::win::ScopedBstr::Get(), ui::AXNodeData::id, ax::mojom::kEditable, ax::mojom::kProgressIndicator, ax::mojom::kReadOnly, ax::mojom::kRestriction, ax::mojom::kRootWebArea, ax::mojom::kTextField, ax::mojom::kValue, ax::mojom::kValueForRange, base::win::ScopedBstr::Receive(), base::win::ScopedBstr::Reset(), and ui::AXNodeData::role.

◆ TEST_F() [143/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IValueProvider_IsReadOnly   
)

Definition at line 4552 of file ax_platform_node_win_unittest.cc.

4552 {
4553 AXNodeData root;
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));
4594 EXPECT_TRUE(is_readonly);
4595
4596 EXPECT_HRESULT_SUCCEEDED(
4597 QueryInterfaceFromNode<IValueProvider>(GetRootAsAXNode()->children()[2])
4598 ->get_IsReadOnly(&is_readonly));
4599 EXPECT_TRUE(is_readonly);
4600
4601 EXPECT_HRESULT_SUCCEEDED(
4602 QueryInterfaceFromNode<IValueProvider>(GetRootAsAXNode()->children()[3])
4603 ->get_IsReadOnly(&is_readonly));
4604 EXPECT_TRUE(is_readonly);
4605}

References ui::AXNodeData::AddIntAttribute(), ui::AXNodeData::AddState(), ui::AXNodeData::child_ids, ui::AXNodeData::id, ax::mojom::kDisabled, ax::mojom::kEditable, ax::mojom::kLink, ax::mojom::kReadOnly, ax::mojom::kRestriction, ax::mojom::kRootWebArea, ax::mojom::kTextField, and ui::AXNodeData::role.

◆ TEST_F() [144/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
IValueProvider_SetValue   
)

Definition at line 4495 of file ax_platform_node_win_unittest.cc.

4495 {
4496 AXNodeData root;
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}

References ui::AXNodeData::AddFloatAttribute(), ui::AXNodeData::AddIntAttribute(), ui::AXNodeData::AddStringAttribute(), ui::AXNodeData::child_ids, EXPECT_UIA_ELEMENTNOTENABLED, base::win::ScopedBstr::Get(), ui::AXNodeData::id, ax::mojom::kProgressIndicator, ax::mojom::kReadOnly, ax::mojom::kRestriction, ax::mojom::kRootWebArea, ax::mojom::kTextField, ax::mojom::kValue, ax::mojom::kValueForRange, base::win::ScopedBstr::Receive(), base::win::ScopedBstr::Reset(), and ui::AXNodeData::role.

◆ TEST_F() [145/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
MojoEventToUIAPropertyTest   
)

Definition at line 4677 of file ax_platform_node_win_unittest.cc.

4677 {
4678 AXNodeData root;
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}

References ui::AXNodeData::AddIntAttribute(), ui::AXNodeData::id, ax::mojom::kCheckBox, ax::mojom::kCheckedState, ax::mojom::kMixed, ax::mojom::kValueChanged, and ui::AXNodeData::role.

◆ TEST_F() [146/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAErrorHandling   
)

Definition at line 3199 of file ax_platform_node_win_unittest.cc.

3199 {
3200 AXNodeData root;
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}

References ui::AXNodeData::id, base::win::ScopedBstr::Receive(), base::win::ScopedSafearray::Receive(), base::win::ScopedVariant::Receive(), and TRUE.

◆ 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}

References ui::AXRelativeBounds::bounds, ui::AXNodeData::id, and ui::AXNodeData::relative_bounds.

◆ TEST_F() [148/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetControllerForPropertyId   
)

Definition at line 1951 of file ax_platform_node_win_unittest.cc.

1951 {
1952 AXNodeData root;
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)

References ui::AXNodeData::AddIntListAttribute(), ui::TestAXNodeWrapper::BuildAllWrappers(), ui::AXNodeData::child_ids, EXPECT_UIA_PROPERTY_ELEMENT_ARRAY_BSTR_EQ, ui::TestAXNodeWrapper::GetOrCreate(), ui::AXNodeData::id, ax::mojom::kControlsIds, ax::mojom::kRootWebArea, ax::mojom::kTab, ax::mojom::kTabPanel, ui::TestAXNodeWrapper::ResetNativeEventTarget(), ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ TEST_F() [149/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetDescribedByPropertyId   
)

Definition at line 1999 of file ax_platform_node_win_unittest.cc.

1999 {
2000 AXNodeData root;
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}

References ui::AXNodeData::AddIntListAttribute(), ui::AXNodeData::child_ids, EXPECT_UIA_PROPERTY_ELEMENT_ARRAY_BSTR_EQ, ui::AXNodeData::id, ax::mojom::kDescribedbyIds, ax::mojom::kMarquee, ax::mojom::kStaticText, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ 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}

References base::win::ScopedSafearray::Get(), ui::AXNodeData::id, and base::win::ScopedSafearray::Receive().

◆ TEST_F() [151/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetFlowsToPropertyId   
)

Definition at line 2100 of file ax_platform_node_win_unittest.cc.

2100 {
2101 AXNodeData root;
2102 std::vector<AXNode::AXID> flowto_ids = {2, 3, 4};
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}

References ui::AXNodeData::AddIntListAttribute(), ui::AXNodeData::child_ids, EXPECT_UIA_PROPERTY_ELEMENT_ARRAY_BSTR_EQ, ui::AXNodeData::id, ax::mojom::kFlowtoIds, ax::mojom::kMarquee, ax::mojom::kStaticText, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ 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)

References ui::AXNodeData::child_ids, ui::AXNode::children(), EXPECT_UIA_ELEMENTNOTAVAILABLE, ui::TestAXNodeWrapper::GetOrCreate(), ui::AXNodeData::id, and ui::TestAXNodeWrapper::ResetNativeEventTarget().

◆ 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}

References ui::AXNodeData::id.

◆ TEST_F() [154/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetPropertySimple   
)

Definition at line 1763 of file ax_platform_node_win_unittest.cc.

1763 {
1764 AXNodeData root;
1766 root.SetName("fake name");
1771 "fake description");
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}

References ui::AXNodeData::AddIntAttribute(), ui::AXNodeData::AddStringAttribute(), ui::AXNodeData::child_ids, EXPECT_UIA_BOOL_EQ, EXPECT_UIA_BSTR_EQ, EXPECT_UIA_INT_EQ, ui::AXNodeData::id, ax::mojom::kAccessKey, ax::mojom::kDescription, ax::mojom::kInvalidState, ax::mojom::kKeyShortcuts, ax::mojom::kLanguage, ax::mojom::kList, ax::mojom::kListItem, ax::mojom::kPosInSet, ax::mojom::kSetSize, base::win::ScopedVariant::ptr(), base::win::ScopedVariant::Receive(), ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ TEST_F() [155/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetPropertyValueClickablePoint   
)

Definition at line 1823 of file ax_platform_node_win_unittest.cc.

1823 {
1824 AXNodeData root;
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)

References ui::AXRelativeBounds::bounds, EXPECT_UIA_DOUBLE_ARRAY_EQ, ui::AXNodeData::id, ax::mojom::kButton, ui::AXNodeData::relative_bounds, and ui::AXNodeData::role.

◆ TEST_F() [156/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetPropertyValueFlowsFromMultiple   
)

Definition at line 2174 of file ax_platform_node_win_unittest.cc.

2174 {
2175 AXNodeData root;
2176 root.id = 1;
2178 root.SetName("root");
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)

References ui::AXNodeData::AddIntListAttribute(), ui::AXNodeData::child_ids, EXPECT_UIA_PROPERTY_UNORDERED_ELEMENT_ARRAY_BSTR_EQ, ui::TestAXNodeWrapper::GetOrCreate(), ui::AXNodeData::id, ax::mojom::kFlowtoIds, ax::mojom::kGenericContainer, ax::mojom::kRootWebArea, ui::TestAXNodeWrapper::ResetNativeEventTarget(), ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ TEST_F() [157/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetPropertyValueFlowsFromNone   
)

Definition at line 2131 of file ax_platform_node_win_unittest.cc.

2131 {
2132 AXNodeData root;
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}

References ui::AXNodeData::id, ax::mojom::kRootWebArea, base::win::ScopedVariant::ptr(), base::win::ScopedVariant::Receive(), ui::AXNodeData::role, ui::AXNodeData::SetName(), and base::win::ScopedVariant::type().

◆ TEST_F() [158/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetPropertyValueFlowsFromSingle   
)

Definition at line 2149 of file ax_platform_node_win_unittest.cc.

2149 {
2150 AXNodeData root;
2151 root.id = 1;
2153 root.SetName("root");
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}

References ui::AXNodeData::AddIntListAttribute(), ui::AXNodeData::child_ids, EXPECT_UIA_PROPERTY_ELEMENT_ARRAY_BSTR_EQ, ui::TestAXNodeWrapper::GetOrCreate(), ui::AXNodeData::id, ax::mojom::kFlowtoIds, ax::mojom::kGenericContainer, ax::mojom::kRootWebArea, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ 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}

References EXPECT_UIA_BSTR_EQ, ui::AXNodeData::id, ax::mojom::kRootWebArea, and ui::AXNodeData::role.

◆ TEST_F() [160/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetPropertyValueIsControlElementIgnoredInvisible   
)

Definition at line 1864 of file ax_platform_node_win_unittest.cc.

1865 {
1866 AXNodeData root;
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}

References ui::AXNodeData::AddState(), ui::AXNodeData::child_ids, EXPECT_UIA_BOOL_EQ, ui::AXNodeData::id, ax::mojom::kButton, ax::mojom::kFocusable, ax::mojom::kGenericContainer, ax::mojom::kIgnored, ax::mojom::kInvisible, ax::mojom::kRootWebArea, ui::AXNodeData::role, and ui::TestAXNodeWrapper::SetGlobalIsWebContent().

◆ TEST_F() [161/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAGetPropertyValueIsDialog   
)

Definition at line 1840 of file ax_platform_node_win_unittest.cc.

1840 {
1841 AXNodeData root;
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}

References ui::AXNodeData::child_ids, EXPECT_UIA_BOOL_EQ, ui::AXNodeData::id, ax::mojom::kAlertDialog, ax::mojom::kDialog, ax::mojom::kRootWebArea, and ui::AXNodeData::role.

◆ 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}

References ui::AXNodeData::id.

◆ 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}

References base::win::ScopedSafearray::Get(), ui::AXNodeData::id, and base::win::ScopedSafearray::Receive().

◆ TEST_F() [164/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAItemStatusPropertyId   
)

Definition at line 2032 of file ax_platform_node_win_unittest.cc.

2032 {
2033 AXNodeData root;
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}

References ui::AXNodeData::AddIntAttribute(), ui::AXNodeData::child_ids, EXPECT_UIA_BSTR_EQ, EXPECT_UIA_VALUE_EQ, ui::AXNodeData::id, ax::mojom::kAscending, ax::mojom::kColumnHeader, ax::mojom::kDescending, ax::mojom::kOther, ax::mojom::kRow, ax::mojom::kRowHeader, ax::mojom::kSortDirection, ax::mojom::kTable, ax::mojom::kUnsorted, and ui::AXNodeData::role.

◆ TEST_F() [165/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAIWindowProviderGetIsModalFalse   
)

Definition at line 2704 of file ax_platform_node_win_unittest.cc.

2704 {
2705 AXNodeData root;
2706 root.id = 1;
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}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::id, ax::mojom::kModal, ax::mojom::kRootWebArea, and ui::AXNodeData::role.

◆ TEST_F() [166/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAIWindowProviderGetIsModalTrue   
)

Definition at line 2723 of file ax_platform_node_win_unittest.cc.

2723 {
2724 AXNodeData root;
2725 root.id = 1;
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}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::id, ax::mojom::kModal, ax::mojom::kRootWebArea, and ui::AXNodeData::role.

◆ TEST_F() [167/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAIWindowProviderGetIsModalUnset   
)

Definition at line 2690 of file ax_platform_node_win_unittest.cc.

2690 {
2691 AXNodeData root;
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}

References ui::AXNodeData::id, ax::mojom::kRootWebArea, and ui::AXNodeData::role.

◆ TEST_F() [168/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAIWindowProviderInvalidArgument   
)

Definition at line 2742 of file ax_platform_node_win_unittest.cc.

2742 {
2743 AXNodeData root;
2744 root.id = 1;
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}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::id, ax::mojom::kModal, ax::mojom::kRootWebArea, and ui::AXNodeData::role.

◆ TEST_F() [169/325]

ui::TEST_F ( AXPlatformNodeWinTest  ,
UIAIWindowProviderNotSupported   
)

Definition at line 2765 of file ax_platform_node_win_unittest.cc.

2765 {
2766 AXNodeData root;
2767 root.id = 1;
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}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::id, ax::mojom::kModal, ax::mojom::kRootWebArea, and ui::AXNodeData::role.

◆ 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)

References EXPECT_UIA_EMPTY, EXPECT_UIA_INT_EQ, ui::AXNodeData::id, ax::mojom::kBanner, ax::mojom::kComplementary, ax::mojom::kContentInfo, ax::mojom::kFooter, ax::mojom::kForm, ax::mojom::kGroup, ax::mojom::kHeading, ax::mojom::kList, ax::mojom::kMain, ax::mojom::kNavigation, ax::mojom::kRegion, ax::mojom::kSearch, ax::mojom::kTable, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ 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}

References EXPECT_UIA_BSTR_EQ, EXPECT_UIA_EMPTY, ui::AXNodeData::id, ax::mojom::kBanner, ax::mojom::kComplementary, ax::mojom::kContentInfo, ax::mojom::kFooter, ax::mojom::kForm, ax::mojom::kGroup, ax::mojom::kHeading, ax::mojom::kList, ax::mojom::kMain, ax::mojom::kNavigation, ax::mojom::kRegion, ax::mojom::kSearch, ax::mojom::kTable, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ 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}

References ui::AXNodeData::child_ids, ui::AXNode::children(), and ui::AXNodeData::id.

◆ TEST_F() [173/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTextPositionAfterCharacter   
)

Definition at line 5853 of file ax_node_position_unittest.cc.

5853 {
5854 TestPositionType text_position = AXNodePosition::CreateTextPosition(
5855 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
5857 ASSERT_NE(nullptr, text_position);
5858 ASSERT_TRUE(text_position->IsTextPosition());
5859 TestPositionType test_position =
5860 text_position->AsLeafTextPositionAfterCharacter();
5861 EXPECT_NE(nullptr, test_position);
5862 EXPECT_TRUE(test_position->IsNullPosition());
5863
5864 text_position = AXNodePosition::CreateTextPosition(
5865 GetTreeID(), inline_box1_.id, 5 /* text_offset */,
5867 ASSERT_NE(nullptr, text_position);
5868 ASSERT_TRUE(text_position->IsTextPosition());
5869 test_position = text_position->AsLeafTextPositionAfterCharacter();
5870 EXPECT_NE(nullptr, test_position);
5871 EXPECT_TRUE(test_position->IsTextPosition());
5872 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
5873 EXPECT_EQ(5, test_position->text_offset());
5874
5875 text_position = AXNodePosition::CreateTextPosition(
5876 GetTreeID(), line_break_.id, 1 /* text_offset */,
5878 ASSERT_NE(nullptr, text_position);
5879 ASSERT_TRUE(text_position->IsTextPosition());
5880 test_position = text_position->AsLeafTextPositionAfterCharacter();
5881 EXPECT_NE(nullptr, test_position);
5882 EXPECT_TRUE(test_position->IsTextPosition());
5883 EXPECT_EQ(line_break_.id, test_position->anchor_id());
5884 EXPECT_EQ(1, test_position->text_offset());
5885
5886 text_position = AXNodePosition::CreateTextPosition(
5887 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
5889 ASSERT_NE(nullptr, text_position);
5890 ASSERT_TRUE(text_position->IsTextPosition());
5891 test_position = text_position->AsLeafTextPositionAfterCharacter();
5892 EXPECT_NE(nullptr, test_position);
5893 EXPECT_TRUE(test_position->IsTextPosition());
5894 EXPECT_EQ(line_break_.id, test_position->anchor_id());
5895 EXPECT_EQ(1, test_position->text_offset());
5896
5897 text_position = AXNodePosition::CreateTextPosition(
5898 GetTreeID(), root_.id, 0 /* text_offset */,
5900 ASSERT_NE(nullptr, text_position);
5901 ASSERT_TRUE(text_position->IsTextPosition());
5902 test_position = text_position->AsLeafTextPositionAfterCharacter();
5903 EXPECT_NE(nullptr, test_position);
5904 EXPECT_TRUE(test_position->IsNullPosition());
5905}
std::unique_ptr< AXPosition< AXNodePosition, AXNode > > TestPositionType

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ax::mojom::kDownstream, and ax::mojom::kUpstream.

◆ TEST_F() [174/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTextPositionAfterCharacterNoAdjustment   
)

Definition at line 5715 of file ax_node_position_unittest.cc.

5715 {
5716 // A text offset that is after "Line 2".
5717 TestPositionType text_position = AXNodePosition::CreateTextPosition(
5718 GetTreeID(), root_.id, 13 /* text_offset */,
5720 ASSERT_NE(nullptr, text_position);
5721 ASSERT_TRUE(text_position->IsTextPosition());
5722 TestPositionType test_position =
5723 text_position->AsLeafTextPositionAfterCharacter();
5724 EXPECT_NE(nullptr, test_position);
5725 EXPECT_TRUE(test_position->IsTextPosition());
5726 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5727 EXPECT_EQ(6, test_position->text_offset());
5728
5729 // A text offset that is before "Line 2".
5730 text_position = AXNodePosition::CreateTextPosition(
5731 GetTreeID(), root_.id, 7 /* text_offset */,
5733 ASSERT_NE(nullptr, text_position);
5734 ASSERT_TRUE(text_position->IsTextPosition());
5735 test_position = text_position->AsLeafTextPositionAfterCharacter();
5736 EXPECT_NE(nullptr, test_position);
5737 EXPECT_TRUE(test_position->IsTextPosition());
5738 EXPECT_EQ(line_break_.id, test_position->anchor_id());
5739 EXPECT_EQ(1, test_position->text_offset());
5740
5741 // A text offset that is on the line break right after "Line 1".
5742 text_position = AXNodePosition::CreateTextPosition(
5743 GetTreeID(), text_field_.id, 6 /* text_offset */,
5745 ASSERT_NE(nullptr, text_position);
5746 ASSERT_TRUE(text_position->IsTextPosition());
5747 test_position = text_position->AsLeafTextPositionAfterCharacter();
5748 EXPECT_NE(nullptr, test_position);
5749 EXPECT_TRUE(test_position->IsTextPosition());
5750 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
5751 EXPECT_EQ(6, test_position->text_offset());
5752 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
5753
5754 text_position = AXNodePosition::CreateTextPosition(
5755 GetTreeID(), text_field_.id, 13 /* text_offset */,
5757 ASSERT_NE(nullptr, text_position);
5758 ASSERT_TRUE(text_position->IsTextPosition());
5759 test_position = text_position->AsLeafTextPositionAfterCharacter();
5760 EXPECT_NE(nullptr, test_position);
5761 EXPECT_TRUE(test_position->IsTextPosition());
5762 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5763 EXPECT_EQ(6, test_position->text_offset());
5764
5765 text_position = AXNodePosition::CreateTextPosition(
5766 GetTreeID(), line_break_.id, 0 /* text_offset */,
5768 ASSERT_NE(nullptr, text_position);
5769 ASSERT_TRUE(text_position->IsTextPosition());
5770 test_position = text_position->AsLeafTextPositionAfterCharacter();
5771 EXPECT_NE(nullptr, test_position);
5772 EXPECT_TRUE(test_position->IsTextPosition());
5773 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
5774 EXPECT_EQ(6, test_position->text_offset());
5775
5776 text_position = AXNodePosition::CreateTextPosition(
5777 GetTreeID(), line_break_.id, 1 /* text_offset */,
5779 ASSERT_NE(nullptr, text_position);
5780 ASSERT_TRUE(text_position->IsTextPosition());
5781 test_position = text_position->AsLeafTextPositionAfterCharacter();
5782 EXPECT_NE(nullptr, test_position);
5783 EXPECT_TRUE(test_position->IsTextPosition());
5784 EXPECT_EQ(line_break_.id, test_position->anchor_id());
5785 EXPECT_EQ(1, test_position->text_offset());
5786
5787 text_position = AXNodePosition::CreateTextPosition(
5788 GetTreeID(), inline_box2_.id, 6 /* text_offset */,
5790 ASSERT_NE(nullptr, text_position);
5791 ASSERT_TRUE(text_position->IsTextPosition());
5792 test_position = text_position->AsLeafTextPositionAfterCharacter();
5793 EXPECT_NE(nullptr, test_position);
5794 EXPECT_TRUE(test_position->IsTextPosition());
5795 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5796 EXPECT_EQ(6, test_position->text_offset());
5797}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ax::mojom::kDownstream, and ax::mojom::kUpstream.

◆ TEST_F() [175/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTextPositionBeforeAndAfterCharacterAtInvalidGraphemeBoundary   
)

Definition at line 5597 of file ax_node_position_unittest.cc.

5598 {
5599#if true
5600 GTEST_SKIP()
5601 << "Skipping, current accessibility library cannot handle grapheme";
5602#else
5603 std::vector<int> text_offsets;
5604 SetTree(CreateMultilingualDocument(&text_offsets));
5605
5606 TestPositionType test_position = AXNodePosition::CreateTextPosition(
5607 GetTreeID(), GetTree()->root()->id(), 4 /* text_offset */,
5609 test_position = test_position->AsLeafTextPositionAfterCharacter();
5610 ASSERT_NE(nullptr, test_position);
5611 EXPECT_TRUE(test_position->IsTextPosition());
5612 EXPECT_EQ(GetTree()->root()->children()[1]->id(), test_position->anchor_id());
5613 // "text_offset_" should have been adjusted to the next grapheme boundary.
5614 EXPECT_EQ(2, test_position->text_offset());
5615 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
5616
5617 test_position = AXNodePosition::CreateTextPosition(
5618 GetTreeID(), GetTree()->root()->id(), 10 /* text_offset */,
5620 test_position = test_position->AsLeafTextPositionBeforeCharacter();
5621 ASSERT_NE(nullptr, test_position);
5622 EXPECT_TRUE(test_position->IsTextPosition());
5623 EXPECT_EQ(GetTree()->root()->children()[2]->id(), test_position->anchor_id());
5624 // "text_offset_" should have been adjusted to the previous grapheme boundary.
5625 EXPECT_EQ(0, test_position->text_offset());
5626 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
5627
5628 test_position = AXNodePosition::CreateTextPosition(
5629 GetTreeID(), GetTree()->root()->id(), 10 /* text_offset */,
5631 test_position = test_position->AsLeafTextPositionBeforeCharacter();
5632 ASSERT_NE(nullptr, test_position);
5633 EXPECT_TRUE(test_position->IsTextPosition());
5634 EXPECT_EQ(GetTree()->root()->children()[2]->id(), test_position->anchor_id());
5635 // The same as above, "text_offset_" should have been adjusted to the previous
5636 // grapheme boundary.
5637 EXPECT_EQ(0, test_position->text_offset());
5638 // An upstream affinity should have had no effect on the outcome and so, it
5639 // should have been reset in order to provide consistent output from the
5640 // method regardless of input affinity.
5641 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
5642#endif // true
5643}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ax::mojom::kDownstream, and ax::mojom::kUpstream.

◆ TEST_F() [176/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTextPositionBeforeAndAfterCharacterWithNullPosition   
)

Definition at line 5583 of file ax_node_position_unittest.cc.

5584 {
5585 TestPositionType null_position = AXNodePosition::CreateNullPosition();
5586 ASSERT_NE(nullptr, null_position);
5587 ASSERT_TRUE(null_position->IsNullPosition());
5588 TestPositionType test_position =
5589 null_position->AsLeafTextPositionBeforeCharacter();
5590 EXPECT_NE(nullptr, test_position);
5591 EXPECT_TRUE(test_position->IsNullPosition());
5592 test_position = null_position->AsLeafTextPositionAfterCharacter();
5593 EXPECT_NE(nullptr, test_position);
5594 EXPECT_TRUE(test_position->IsNullPosition());
5595}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition().

◆ TEST_F() [177/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTextPositionBeforeCharacter   
)

Definition at line 5799 of file ax_node_position_unittest.cc.

5799 {
5800 TestPositionType text_position = AXNodePosition::CreateTextPosition(
5801 GetTreeID(), inline_box1_.id, 3 /* text_offset */,
5803 ASSERT_NE(nullptr, text_position);
5804 ASSERT_TRUE(text_position->IsTextPosition());
5805 TestPositionType test_position =
5806 text_position->AsLeafTextPositionBeforeCharacter();
5807 EXPECT_NE(nullptr, test_position);
5808 EXPECT_TRUE(test_position->IsTextPosition());
5809 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
5810 EXPECT_EQ(3, test_position->text_offset());
5811
5812 text_position = AXNodePosition::CreateTextPosition(
5813 GetTreeID(), line_break_.id, 1 /* text_offset */,
5815 ASSERT_NE(nullptr, text_position);
5816 ASSERT_TRUE(text_position->IsTextPosition());
5817 test_position = text_position->AsLeafTextPositionBeforeCharacter();
5818 EXPECT_NE(nullptr, test_position);
5819 EXPECT_TRUE(test_position->IsTextPosition());
5820 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5821 EXPECT_EQ(0, test_position->text_offset());
5822
5823 text_position = AXNodePosition::CreateTextPosition(
5824 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
5826 ASSERT_NE(nullptr, text_position);
5827 ASSERT_TRUE(text_position->IsTextPosition());
5828 test_position = text_position->AsLeafTextPositionBeforeCharacter();
5829 EXPECT_NE(nullptr, test_position);
5830 EXPECT_TRUE(test_position->IsTextPosition());
5831 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5832 EXPECT_EQ(0, test_position->text_offset());
5833
5834 text_position = AXNodePosition::CreateTextPosition(
5835 GetTreeID(), inline_box2_.id, 6 /* text_offset */,
5837 ASSERT_NE(nullptr, text_position);
5838 ASSERT_TRUE(text_position->IsTextPosition());
5839 test_position = text_position->AsLeafTextPositionBeforeCharacter();
5840 EXPECT_NE(nullptr, test_position);
5841 EXPECT_TRUE(test_position->IsNullPosition());
5842
5843 text_position = AXNodePosition::CreateTextPosition(
5844 GetTreeID(), root_.id, 13 /* text_offset */,
5846 ASSERT_NE(nullptr, text_position);
5847 ASSERT_TRUE(text_position->IsTextPosition());
5848 test_position = text_position->AsLeafTextPositionBeforeCharacter();
5849 EXPECT_NE(nullptr, test_position);
5850 EXPECT_TRUE(test_position->IsNullPosition());
5851}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ax::mojom::kDownstream, and ax::mojom::kUpstream.

◆ TEST_F() [178/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTextPositionBeforeCharacterNoAdjustment   
)

Definition at line 5645 of file ax_node_position_unittest.cc.

5645 {
5646 // A text offset that is on the line break right after "Line 1".
5647 TestPositionType text_position = AXNodePosition::CreateTextPosition(
5648 GetTreeID(), root_.id, 6 /* text_offset */,
5650 ASSERT_NE(nullptr, text_position);
5651 ASSERT_TRUE(text_position->IsTextPosition());
5652 TestPositionType test_position =
5653 text_position->AsLeafTextPositionBeforeCharacter();
5654 EXPECT_NE(nullptr, test_position);
5655 EXPECT_TRUE(test_position->IsTextPosition());
5656 EXPECT_EQ(line_break_.id, test_position->anchor_id());
5657 EXPECT_EQ(0, test_position->text_offset());
5658
5659 // A text offset that is before the line break right after "Line 1".
5660 text_position = AXNodePosition::CreateTextPosition(
5661 GetTreeID(), text_field_.id, 6 /* text_offset */,
5663 ASSERT_NE(nullptr, text_position);
5664 ASSERT_TRUE(text_position->IsTextPosition());
5665 test_position = text_position->AsLeafTextPositionBeforeCharacter();
5666 EXPECT_NE(nullptr, test_position);
5667 EXPECT_TRUE(test_position->IsTextPosition());
5668 EXPECT_EQ(line_break_.id, test_position->anchor_id());
5669 EXPECT_EQ(0, test_position->text_offset());
5670 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
5671
5672 text_position = AXNodePosition::CreateTextPosition(
5673 GetTreeID(), text_field_.id, 13 /* text_offset */,
5675 ASSERT_NE(nullptr, text_position);
5676 ASSERT_TRUE(text_position->IsTextPosition());
5677 test_position = text_position->AsLeafTextPositionBeforeCharacter();
5678 EXPECT_NE(nullptr, test_position);
5679 EXPECT_TRUE(test_position->IsNullPosition());
5680
5681 text_position = AXNodePosition::CreateTextPosition(
5682 GetTreeID(), static_text1_.id, 6 /* text_offset */,
5684 ASSERT_NE(nullptr, text_position);
5685 ASSERT_TRUE(text_position->IsTextPosition());
5686 test_position = text_position->AsLeafTextPositionBeforeCharacter();
5687 EXPECT_NE(nullptr, test_position);
5688 EXPECT_TRUE(test_position->IsTextPosition());
5689 EXPECT_EQ(line_break_.id, test_position->anchor_id());
5690 EXPECT_EQ(0, test_position->text_offset());
5691
5692 text_position = AXNodePosition::CreateTextPosition(
5693 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
5695 ASSERT_NE(nullptr, text_position);
5696 ASSERT_TRUE(text_position->IsTextPosition());
5697 test_position = text_position->AsLeafTextPositionBeforeCharacter();
5698 EXPECT_NE(nullptr, test_position);
5699 EXPECT_TRUE(test_position->IsTextPosition());
5700 EXPECT_EQ(line_break_.id, test_position->anchor_id());
5701 EXPECT_EQ(0, test_position->text_offset());
5702
5703 text_position = AXNodePosition::CreateTextPosition(
5704 GetTreeID(), line_break_.id, 1 /* text_offset */,
5706 ASSERT_NE(nullptr, text_position);
5707 ASSERT_TRUE(text_position->IsTextPosition());
5708 test_position = text_position->AsLeafTextPositionBeforeCharacter();
5709 EXPECT_NE(nullptr, test_position);
5710 EXPECT_TRUE(test_position->IsTextPosition());
5711 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5712 EXPECT_EQ(0, test_position->text_offset());
5713}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ax::mojom::kDownstream, and ax::mojom::kUpstream.

◆ TEST_F() [179/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTextPositionWithNullPosition   
)

Definition at line 3247 of file ax_node_position_unittest.cc.

3247 {
3248 TestPositionType null_position = AXNodePosition::CreateNullPosition();
3249 ASSERT_NE(nullptr, null_position);
3250 TestPositionType test_position = null_position->AsLeafTextPosition();
3251 ASSERT_NE(nullptr, test_position);
3252 EXPECT_TRUE(test_position->IsNullPosition());
3253}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition().

◆ TEST_F() [180/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTextPositionWithTextPosition   
)

Definition at line 3296 of file ax_node_position_unittest.cc.

3296 {
3297 // Create a text position pointing to the end of the root (an "after text"
3298 // position).
3299 TestPositionType text_position = AXNodePosition::CreateTextPosition(
3300 GetTreeID(), root_.id, 13 /* text_offset */,
3302 ASSERT_NE(nullptr, text_position);
3303 ASSERT_TRUE(text_position->IsTextPosition());
3304 ASSERT_FALSE(text_position->IsLeafTextPosition());
3305 TestPositionType test_position = text_position->AsLeafTextPosition();
3306 ASSERT_NE(nullptr, test_position);
3307 EXPECT_TRUE(test_position->IsLeafTextPosition());
3308 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3309 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
3310 EXPECT_EQ(6, test_position->text_offset());
3311 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3312
3313 text_position = AXNodePosition::CreateTextPosition(
3314 GetTreeID(), root_.id, 0 /* text_offset */,
3316 ASSERT_NE(nullptr, text_position);
3317 test_position = text_position->AsLeafTextPosition();
3318 ASSERT_NE(nullptr, test_position);
3319 EXPECT_TRUE(test_position->IsTextPosition());
3320 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3321 EXPECT_EQ(button_.id, test_position->anchor_id());
3322 EXPECT_EQ(0, test_position->text_offset());
3323 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3324
3325 text_position = AXNodePosition::CreateTextPosition(
3326 GetTreeID(), text_field_.id, 0 /* text_offset */,
3328 ASSERT_NE(nullptr, text_position);
3329 test_position = text_position->AsLeafTextPosition();
3330 ASSERT_NE(nullptr, test_position);
3331 EXPECT_TRUE(test_position->IsLeafTextPosition());
3332 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3333 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3334 EXPECT_EQ(0, test_position->text_offset());
3335 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3336
3337 text_position = AXNodePosition::CreateTextPosition(
3338 GetTreeID(), text_field_.id, 0 /* text_offset */,
3340 ASSERT_NE(nullptr, text_position);
3341 test_position = text_position->AsLeafTextPosition();
3342 ASSERT_NE(nullptr, test_position);
3343 EXPECT_TRUE(test_position->IsLeafTextPosition());
3344 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3345 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3346 EXPECT_EQ(0, test_position->text_offset());
3347 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3348
3349 // Create a text position on the root, pointing to the line break character
3350 // inside the text field but with an upstream affinity which will cause the
3351 // leaf text position to be placed after the text of the first inline text
3352 // box.
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(inline_box1_.id, test_position->anchor_id());
3362 EXPECT_EQ(6, 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 but with an upstream affinity which will cause the leaf text position
3367 // to be placed after the text of the first inline text box.
3368 text_position = AXNodePosition::CreateTextPosition(
3369 GetTreeID(), text_field_.id, 6 /* text_offset */,
3371 ASSERT_NE(nullptr, text_position);
3372 test_position = text_position->AsLeafTextPosition();
3373 ASSERT_NE(nullptr, test_position);
3374 EXPECT_TRUE(test_position->IsLeafTextPosition());
3375 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3376 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3377 EXPECT_EQ(6, test_position->text_offset());
3378 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3379
3380 // Create a text position on the root, pointing to the line break character
3381 // inside the text field.
3382 text_position = AXNodePosition::CreateTextPosition(
3383 GetTreeID(), root_.id, 6 /* text_offset */,
3385 ASSERT_NE(nullptr, text_position);
3386 test_position = text_position->AsLeafTextPosition();
3387 ASSERT_NE(nullptr, test_position);
3388 EXPECT_TRUE(test_position->IsLeafTextPosition());
3389 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3390 EXPECT_EQ(line_break_.id, test_position->anchor_id());
3391 EXPECT_EQ(0, test_position->text_offset());
3392 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3393
3394 // Create a text position pointing to the line break character inside the text
3395 // field.
3396 text_position = AXNodePosition::CreateTextPosition(
3397 GetTreeID(), text_field_.id, 6 /* text_offset */,
3399 ASSERT_NE(nullptr, text_position);
3400 test_position = text_position->AsLeafTextPosition();
3401 ASSERT_NE(nullptr, test_position);
3402 EXPECT_TRUE(test_position->IsLeafTextPosition());
3403 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3404 EXPECT_EQ(line_break_.id, test_position->anchor_id());
3405 EXPECT_EQ(0, test_position->text_offset());
3406 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3407
3408 // Create a text position pointing to the offset after the last character in
3409 // the text field, (an "after text" position).
3410 text_position = AXNodePosition::CreateTextPosition(
3411 GetTreeID(), text_field_.id, 13 /* text_offset */,
3413 ASSERT_NE(nullptr, text_position);
3414 test_position = text_position->AsLeafTextPosition();
3415 ASSERT_NE(nullptr, test_position);
3416 EXPECT_TRUE(test_position->IsLeafTextPosition());
3417 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3418 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
3419 EXPECT_EQ(6, test_position->text_offset());
3420 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3421
3422 // Create a root text position that points to the middle of a leaf text
3423 // position, should maintain its relative text_offset ("Lin<e> 2")
3424 text_position = AXNodePosition::CreateTextPosition(
3425 GetTreeID(), root_.id, 10 /* text_offset */,
3427 ASSERT_NE(nullptr, text_position);
3428 test_position = text_position->AsLeafTextPosition();
3429 ASSERT_NE(nullptr, test_position);
3430 EXPECT_TRUE(test_position->IsLeafTextPosition());
3431 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3432 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
3433 EXPECT_EQ(3, test_position->text_offset());
3434 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3435
3436 // Create a root text position that points to the middle of an equivalent leaf
3437 // text position. It should maintain its relative text_offset ("Lin<e> 2")
3438 text_position = AXNodePosition::CreateTextPosition(
3439 GetTreeID(), root_.id, 10 /* text_offset */,
3441 ASSERT_NE(nullptr, text_position);
3442 test_position = text_position->AsLeafTextPosition();
3443 ASSERT_NE(nullptr, test_position);
3444 EXPECT_TRUE(test_position->IsLeafTextPosition());
3445 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3446 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
3447 EXPECT_EQ(3, test_position->text_offset());
3448 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3449}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ax::mojom::kDownstream, and ax::mojom::kUpstream.

◆ TEST_F() [181/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTextPositionWithTextPositionAndEmptyTextSandwich   
)

Definition at line 3451 of file ax_node_position_unittest.cc.

3451 {
3452 // This test updates the tree structure to test a specific edge case -
3453 // AsLeafTextPosition when there is an empty leaf text node between
3454 // two non-empty text nodes.
3455 AXNodeData root_data;
3456 root_data.id = 1;
3458
3459 AXNodeData text_data;
3460 text_data.id = 2;
3462 text_data.SetName("some text");
3463
3464 AXNodeData button_data;
3465 button_data.id = 3;
3466 button_data.role = ax::mojom::Role::kButton;
3467 button_data.SetName("");
3468
3469 AXNodeData more_text_data;
3470 more_text_data.id = 4;
3471 more_text_data.role = ax::mojom::Role::kInlineTextBox;
3472 more_text_data.SetName("more text");
3473
3474 root_data.child_ids = {text_data.id, button_data.id, more_text_data.id};
3475
3476 SetTree(CreateAXTree({root_data, text_data, button_data, more_text_data}));
3477
3478 // Create a text position on the root pointing to just after the
3479 // first static text leaf node.
3480 TestPositionType text_position = AXNodePosition::CreateTextPosition(
3481 GetTreeID(), root_data.id, 9 /* text_offset */,
3483 ASSERT_NE(nullptr, text_position);
3484 ASSERT_TRUE(text_position->IsTextPosition());
3485 ASSERT_FALSE(text_position->IsLeafTextPosition());
3486 TestPositionType test_position = text_position->AsLeafTextPosition();
3487 ASSERT_NE(nullptr, test_position);
3488 EXPECT_TRUE(test_position->IsLeafTextPosition());
3489 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3490 EXPECT_EQ(button_data.id, test_position->anchor_id());
3491 EXPECT_EQ(0, test_position->text_offset());
3492 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3493
3494 text_position = AXNodePosition::CreateTextPosition(
3495 GetTreeID(), root_data.id, 9 /* text_offset */,
3497 ASSERT_NE(nullptr, text_position);
3498 test_position = text_position->AsLeafTextPosition();
3499 ASSERT_NE(nullptr, test_position);
3500 EXPECT_TRUE(test_position->IsLeafTextPosition());
3501 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3502 EXPECT_EQ(text_data.id, test_position->anchor_id());
3503 EXPECT_EQ(9, test_position->text_offset());
3504 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3505}

References ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXNodeData::id, ax::mojom::kButton, ax::mojom::kDownstream, ax::mojom::kInlineTextBox, ax::mojom::kRootWebArea, ax::mojom::kUpstream, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ TEST_F() [182/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTextPositionWithTreePosition   
)

Definition at line 3255 of file ax_node_position_unittest.cc.

3255 {
3256 // Create a tree position pointing to the first static text node inside the
3257 // text field.
3258 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
3259 GetTreeID(), text_field_.id, 0 /* child_index */);
3260 ASSERT_NE(nullptr, tree_position);
3261 TestPositionType test_position = tree_position->AsLeafTextPosition();
3262 ASSERT_NE(nullptr, test_position);
3263 EXPECT_TRUE(test_position->IsLeafTextPosition());
3264 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3265 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3266 EXPECT_EQ(0, test_position->text_offset());
3267 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3268
3269 // Create a tree position pointing to the line break node inside the text
3270 // field.
3271 tree_position = AXNodePosition::CreateTreePosition(
3272 GetTreeID(), text_field_.id, 1 /* child_index */);
3273 ASSERT_NE(nullptr, tree_position);
3274 test_position = tree_position->AsLeafTextPosition();
3275 ASSERT_NE(nullptr, test_position);
3276 EXPECT_TRUE(test_position->IsLeafTextPosition());
3277 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3278 EXPECT_EQ(line_break_.id, test_position->anchor_id());
3279 EXPECT_EQ(0, test_position->text_offset());
3280 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3281
3282 // Create a text position pointing to the second static text node inside the
3283 // text field.
3284 tree_position = AXNodePosition::CreateTreePosition(
3285 GetTreeID(), text_field_.id, 2 /* child_index */);
3286 ASSERT_NE(nullptr, tree_position);
3287 test_position = tree_position->AsLeafTextPosition();
3288 ASSERT_NE(nullptr, test_position);
3289 EXPECT_TRUE(test_position->IsLeafTextPosition());
3290 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3291 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
3292 EXPECT_EQ(0, test_position->text_offset());
3293 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3294}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), and ax::mojom::kDownstream.

◆ TEST_F() [183/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTreePositionWithNullPosition   
)

Definition at line 3067 of file ax_node_position_unittest.cc.

3067 {
3068 TestPositionType null_position = AXNodePosition::CreateNullPosition();
3069 ASSERT_NE(nullptr, null_position);
3070 TestPositionType test_position = null_position->AsLeafTreePosition();
3071 ASSERT_NE(nullptr, test_position);
3072 EXPECT_TRUE(test_position->IsNullPosition());
3073}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition().

◆ TEST_F() [184/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTreePositionWithTextPosition   
)

Definition at line 3113 of file ax_node_position_unittest.cc.

3113 {
3114 // Create a text position pointing to the end of the root (an "after text"
3115 // position).
3116 TestPositionType text_position = AXNodePosition::CreateTextPosition(
3117 GetTreeID(), root_.id, 13 /* text_offset */,
3119 ASSERT_NE(nullptr, text_position);
3120 ASSERT_TRUE(text_position->IsTextPosition());
3121 TestPositionType test_position = text_position->AsLeafTreePosition();
3122 ASSERT_NE(nullptr, test_position);
3123 EXPECT_TRUE(test_position->IsLeafTreePosition());
3124 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3125 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
3126 EXPECT_EQ(0, test_position->child_index());
3127
3128 text_position = AXNodePosition::CreateTextPosition(
3129 GetTreeID(), root_.id, 0 /* text_offset */,
3131 ASSERT_NE(nullptr, text_position);
3132 ASSERT_TRUE(text_position->IsTextPosition());
3133 test_position = text_position->AsLeafTreePosition();
3134 ASSERT_NE(nullptr, test_position);
3135 EXPECT_TRUE(test_position->IsLeafTreePosition());
3136 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3137 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3138 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3139
3140 text_position = AXNodePosition::CreateTextPosition(
3141 GetTreeID(), text_field_.id, 0 /* text_offset */,
3143 ASSERT_NE(nullptr, text_position);
3144 ASSERT_TRUE(text_position->IsTextPosition());
3145 test_position = text_position->AsLeafTreePosition();
3146 ASSERT_NE(nullptr, test_position);
3147 EXPECT_TRUE(test_position->IsLeafTreePosition());
3148 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3149 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3150 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3151
3152 text_position = AXNodePosition::CreateTextPosition(
3153 GetTreeID(), text_field_.id, 0 /* text_offset */,
3155 ASSERT_NE(nullptr, text_position);
3156 ASSERT_TRUE(text_position->IsTextPosition());
3157 test_position = text_position->AsLeafTreePosition();
3158 ASSERT_NE(nullptr, test_position);
3159 EXPECT_TRUE(test_position->IsLeafTreePosition());
3160 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3161 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3162 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3163
3164 // Create a text position on the root, pointing to the line break character
3165 // inside the text field but with an upstream affinity which will cause the
3166 // leaf text position to be placed after the text of the first inline text
3167 // box.
3168 text_position = AXNodePosition::CreateTextPosition(
3169 GetTreeID(), root_.id, 6 /* text_offset */,
3171 ASSERT_NE(nullptr, text_position);
3172 ASSERT_TRUE(text_position->IsTextPosition());
3173 test_position = text_position->AsLeafTreePosition();
3174 ASSERT_NE(nullptr, test_position);
3175 EXPECT_TRUE(test_position->IsLeafTreePosition());
3176 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3177 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3178 EXPECT_EQ(0, test_position->child_index());
3179
3180 // Create a text position pointing to the line break character inside the text
3181 // field but with an upstream affinity which will cause the leaf text position
3182 // to be placed after the text of the first inline text box.
3183 text_position = AXNodePosition::CreateTextPosition(
3184 GetTreeID(), text_field_.id, 6 /* text_offset */,
3186 ASSERT_NE(nullptr, text_position);
3187 test_position = text_position->AsLeafTreePosition();
3188 ASSERT_NE(nullptr, test_position);
3189 EXPECT_TRUE(test_position->IsLeafTreePosition());
3190 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3191 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3192 EXPECT_EQ(0, test_position->child_index());
3193
3194 // Create a text position on the root, pointing to the line break character
3195 // inside the text field.
3196 text_position = AXNodePosition::CreateTextPosition(
3197 GetTreeID(), root_.id, 6 /* text_offset */,
3199 ASSERT_NE(nullptr, text_position);
3200 test_position = text_position->AsLeafTreePosition();
3201 ASSERT_NE(nullptr, test_position);
3202 EXPECT_TRUE(test_position->IsLeafTreePosition());
3203 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3204 EXPECT_EQ(line_break_.id, test_position->anchor_id());
3205 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3206
3207 // Create a text position pointing to the line break character inside the text
3208 // field.
3209 text_position = AXNodePosition::CreateTextPosition(
3210 GetTreeID(), text_field_.id, 6 /* text_offset */,
3212 ASSERT_NE(nullptr, text_position);
3213 test_position = text_position->AsLeafTreePosition();
3214 ASSERT_NE(nullptr, test_position);
3215 EXPECT_TRUE(test_position->IsLeafTreePosition());
3216 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3217 EXPECT_EQ(line_break_.id, test_position->anchor_id());
3218 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3219
3220 // Create a text position pointing to the offset after the last character in
3221 // the text field, (an "after text" position).
3222 text_position = AXNodePosition::CreateTextPosition(
3223 GetTreeID(), text_field_.id, 13 /* text_offset */,
3225 ASSERT_NE(nullptr, text_position);
3226 test_position = text_position->AsLeafTreePosition();
3227 ASSERT_NE(nullptr, test_position);
3228 EXPECT_TRUE(test_position->IsLeafTreePosition());
3229 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3230 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
3231 EXPECT_EQ(0, test_position->child_index());
3232
3233 // Create a root text position that points to the middle of an equivalent leaf
3234 // text position.
3235 text_position = AXNodePosition::CreateTextPosition(
3236 GetTreeID(), root_.id, 10 /* text_offset */,
3238 ASSERT_NE(nullptr, text_position);
3239 test_position = text_position->AsLeafTreePosition();
3240 ASSERT_NE(nullptr, test_position);
3241 EXPECT_TRUE(test_position->IsLeafTreePosition());
3242 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3243 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
3244 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3245}

References ui::AXPosition< AXNodePosition, AXNode >::BEFORE_TEXT, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ax::mojom::kDownstream, and ax::mojom::kUpstream.

◆ TEST_F() [185/325]

ui::TEST_F ( AXPositionTest  ,
AsLeafTreePositionWithTreePosition   
)

Definition at line 3075 of file ax_node_position_unittest.cc.

3075 {
3076 // Create a tree position pointing to the first static text node inside the
3077 // text field: a "before children" position.
3078 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
3079 GetTreeID(), text_field_.id, 0 /* child_index */);
3080 ASSERT_NE(nullptr, tree_position);
3081 TestPositionType test_position = tree_position->AsLeafTreePosition();
3082 ASSERT_NE(nullptr, test_position);
3083 EXPECT_TRUE(test_position->IsLeafTreePosition());
3084 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3085 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3086 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3087
3088 // Create a tree position pointing to the line break node inside the text
3089 // field.
3090 tree_position = AXNodePosition::CreateTreePosition(
3091 GetTreeID(), text_field_.id, 1 /* child_index */);
3092 ASSERT_NE(nullptr, tree_position);
3093 test_position = tree_position->AsLeafTreePosition();
3094 ASSERT_NE(nullptr, test_position);
3095 EXPECT_TRUE(test_position->IsLeafTreePosition());
3096 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3097 EXPECT_EQ(line_break_.id, test_position->anchor_id());
3098 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3099
3100 // Create a text position pointing to the second static text node inside the
3101 // text field.
3102 tree_position = AXNodePosition::CreateTreePosition(
3103 GetTreeID(), text_field_.id, 2 /* child_index */);
3104 ASSERT_NE(nullptr, tree_position);
3105 test_position = tree_position->AsLeafTreePosition();
3106 ASSERT_NE(nullptr, test_position);
3107 EXPECT_TRUE(test_position->IsLeafTreePosition());
3108 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3109 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
3110 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3111}

References ui::AXPosition< AXNodePosition, AXNode >::BEFORE_TEXT, and ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition().

◆ TEST_F() [186/325]

ui::TEST_F ( AXPositionTest  ,
AsTextPositionWithNullPosition   
)

Definition at line 2995 of file ax_node_position_unittest.cc.

2995 {
2996 TestPositionType null_position = AXNodePosition::CreateNullPosition();
2997 ASSERT_NE(nullptr, null_position);
2998 TestPositionType test_position = null_position->AsTextPosition();
2999 ASSERT_NE(nullptr, test_position);
3000 EXPECT_TRUE(test_position->IsNullPosition());
3001}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition().

◆ TEST_F() [187/325]

ui::TEST_F ( AXPositionTest  ,
AsTextPositionWithTextPosition   
)

Definition at line 3051 of file ax_node_position_unittest.cc.

3051 {
3052 TestPositionType text_position = AXNodePosition::CreateTextPosition(
3053 GetTreeID(), text_field_.id, 0 /* text_offset */,
3055 ASSERT_NE(nullptr, text_position);
3056 ASSERT_TRUE(text_position->IsTextPosition());
3057 TestPositionType test_position = text_position->AsTextPosition();
3058 ASSERT_NE(nullptr, test_position);
3059 EXPECT_TRUE(test_position->IsTextPosition());
3060 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3061 EXPECT_EQ(text_field_.id, test_position->anchor_id());
3062 EXPECT_EQ(0, test_position->text_offset());
3063 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3064 EXPECT_EQ(AXNodePosition::INVALID_INDEX, test_position->child_index());
3065}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::INVALID_INDEX, and ax::mojom::kDownstream.

◆ TEST_F() [188/325]

ui::TEST_F ( AXPositionTest  ,
AsTextPositionWithTreePosition   
)

Definition at line 3003 of file ax_node_position_unittest.cc.

3003 {
3004 // Create a tree position pointing to the line break node inside the text
3005 // field.
3006 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
3007 GetTreeID(), text_field_.id, 1 /* child_index */);
3008 ASSERT_NE(nullptr, tree_position);
3009 TestPositionType test_position = tree_position->AsTextPosition();
3010 ASSERT_NE(nullptr, test_position);
3011 EXPECT_TRUE(test_position->IsTextPosition());
3012 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3013 EXPECT_EQ(text_field_.id, test_position->anchor_id());
3014 // The created text position should point to the 6th character inside the text
3015 // field, i.e. the line break.
3016 EXPECT_EQ(6, test_position->text_offset());
3017 // But its child index should be unchanged.
3018 EXPECT_EQ(1, test_position->child_index());
3019 // And the affinity cannot be anything other than downstream because we
3020 // haven't moved up the tree and so there was no opportunity to introduce any
3021 // ambiguity regarding the new position.
3022 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3023
3024 // Test for a "before text" position.
3025 tree_position = AXNodePosition::CreateTreePosition(
3026 GetTreeID(), inline_box1_.id, AXNodePosition::BEFORE_TEXT);
3027 ASSERT_NE(nullptr, tree_position);
3028 test_position = tree_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(inline_box1_.id, test_position->anchor_id());
3033 EXPECT_EQ(0, test_position->text_offset());
3034 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3035 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3036
3037 // Test for an "after text" position.
3038 tree_position = AXNodePosition::CreateTreePosition(
3039 GetTreeID(), inline_box1_.id, 0 /* child_index */);
3040 ASSERT_NE(nullptr, tree_position);
3041 test_position = tree_position->AsTextPosition();
3042 ASSERT_NE(nullptr, test_position);
3043 EXPECT_TRUE(test_position->IsTextPosition());
3044 EXPECT_EQ(GetTreeID(), test_position->tree_id());
3045 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3046 EXPECT_EQ(6, test_position->text_offset());
3047 EXPECT_EQ(0, test_position->child_index());
3048 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3049}

References ui::AXPosition< AXNodePosition, AXNode >::BEFORE_TEXT, ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), and ax::mojom::kDownstream.

◆ TEST_F() [189/325]

ui::TEST_F ( AXPositionTest  ,
AsTreePositionWithNullPosition   
)

Definition at line 2927 of file ax_node_position_unittest.cc.

2927 {
2928 TestPositionType null_position = AXNodePosition::CreateNullPosition();
2929 ASSERT_NE(nullptr, null_position);
2930 TestPositionType test_position = null_position->AsTreePosition();
2931 ASSERT_NE(nullptr, test_position);
2932 EXPECT_TRUE(test_position->IsNullPosition());
2933}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition().

◆ TEST_F() [190/325]

ui::TEST_F ( AXPositionTest  ,
AsTreePositionWithTextPosition   
)

Definition at line 2948 of file ax_node_position_unittest.cc.

2948 {
2949 // Create a text position pointing to the last character in the text field.
2950 TestPositionType text_position = AXNodePosition::CreateTextPosition(
2951 GetTreeID(), text_field_.id, 12 /* text_offset */,
2953 ASSERT_NE(nullptr, text_position);
2954 ASSERT_TRUE(text_position->IsTextPosition());
2955 TestPositionType test_position = text_position->AsTreePosition();
2956 ASSERT_NE(nullptr, test_position);
2957 EXPECT_TRUE(test_position->IsTreePosition());
2958 EXPECT_EQ(GetTreeID(), test_position->tree_id());
2959 EXPECT_EQ(text_field_.id, test_position->anchor_id());
2960 // The created tree position should point to the second static text node
2961 // inside the text field.
2962 EXPECT_EQ(2, test_position->child_index());
2963 // But its text offset should be unchanged.
2964 EXPECT_EQ(12, test_position->text_offset());
2965
2966 // Test for a "before text" position.
2967 text_position = AXNodePosition::CreateTextPosition(
2968 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
2970 ASSERT_NE(nullptr, text_position);
2971 ASSERT_TRUE(text_position->IsTextPosition());
2972 test_position = text_position->AsTreePosition();
2973 ASSERT_NE(nullptr, test_position);
2974 EXPECT_TRUE(test_position->IsTreePosition());
2975 EXPECT_EQ(GetTreeID(), test_position->tree_id());
2976 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
2977 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
2978 EXPECT_EQ(0, test_position->text_offset());
2979
2980 // Test for an "after text" position.
2981 text_position = AXNodePosition::CreateTextPosition(
2982 GetTreeID(), inline_box2_.id, 6 /* text_offset */,
2984 ASSERT_NE(nullptr, text_position);
2985 ASSERT_TRUE(text_position->IsTextPosition());
2986 test_position = text_position->AsTreePosition();
2987 ASSERT_NE(nullptr, test_position);
2988 EXPECT_TRUE(test_position->IsTreePosition());
2989 EXPECT_EQ(GetTreeID(), test_position->tree_id());
2990 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
2991 EXPECT_EQ(0, test_position->child_index());
2992 EXPECT_EQ(6, test_position->text_offset());
2993}

References ui::AXPosition< AXNodePosition, AXNode >::BEFORE_TEXT, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kDownstream.

◆ TEST_F() [191/325]

ui::TEST_F ( AXPositionTest  ,
AsTreePositionWithTreePosition   
)

Definition at line 2935 of file ax_node_position_unittest.cc.

2935 {
2936 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
2937 GetTreeID(), root_.id, 1 /* child_index */);
2938 ASSERT_NE(nullptr, tree_position);
2939 TestPositionType test_position = tree_position->AsTreePosition();
2940 ASSERT_NE(nullptr, test_position);
2941 EXPECT_TRUE(test_position->IsTreePosition());
2942 EXPECT_EQ(GetTreeID(), test_position->tree_id());
2943 EXPECT_EQ(root_.id, test_position->anchor_id());
2944 EXPECT_EQ(1, test_position->child_index());
2945 EXPECT_EQ(AXNodePosition::INVALID_OFFSET, test_position->text_offset());
2946}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), and ui::AXPosition< AXNodePosition, AXNode >::INVALID_OFFSET.

◆ TEST_F() [192/325]

ui::TEST_F ( AXPositionTest  ,
AsUnignoredPosition   
)

Definition at line 3507 of file ax_node_position_unittest.cc.

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

References ui::AXNodeData::AddState(), ui::AXPosition< AXNodePosition, AXNode >::BEFORE_TEXT, ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kGenericContainer, ax::mojom::kIgnored, ax::mojom::kInlineTextBox, kMoveBackward, kMoveForward, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ TEST_F() [193/325]

ui::TEST_F ( AXPositionTest  ,
AsValidPosition   
)

Definition at line 5920 of file ax_node_position_unittest.cc.

5920 {
5921 AXNodeData root_data;
5922 root_data.id = 1;
5924
5925 AXNodeData text_data;
5926 text_data.id = 2;
5928 text_data.SetName("some text");
5929
5930 root_data.child_ids = {text_data.id};
5931
5932 SetTree(CreateAXTree({root_data, text_data}));
5933
5934 // Create a text position at MaxTextOffset.
5935 TestPositionType text_position = AXNodePosition::CreateTextPosition(
5936 GetTreeID(), text_data.id, 9 /* text_offset */,
5938 ASSERT_NE(nullptr, text_position);
5939 EXPECT_TRUE(text_position->IsTextPosition());
5940 EXPECT_TRUE(text_position->IsValid());
5941 EXPECT_EQ(9, text_position->text_offset());
5942
5943 // Test basic cases with static MaxTextOffset
5944 TestPositionType test_position = text_position->CreateNextCharacterPosition(
5945 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
5946 EXPECT_TRUE(test_position->IsValid());
5947 ASSERT_NE(nullptr, test_position);
5948 EXPECT_TRUE(test_position->IsTextPosition());
5949 EXPECT_EQ(text_data.id, test_position->anchor_id());
5950 EXPECT_EQ(9, test_position->text_offset());
5951 test_position = text_position->CreateNextCharacterPosition(
5952 AXBoundaryBehavior::CrossBoundary);
5953 ASSERT_NE(nullptr, test_position);
5954 EXPECT_TRUE(test_position->IsNullPosition());
5955
5956 // AsValidPosition should not change any fields on already-valid positions.
5957 EXPECT_TRUE(text_position->IsValid());
5958 test_position = text_position->AsValidPosition();
5959 EXPECT_TRUE(test_position->IsValid());
5960 EXPECT_EQ(*test_position, *text_position);
5961
5962 // Now make a change to shorten MaxTextOffset. Ensure that this position is
5963 // invalid, then call AsValidPosition and ensure that it is now valid.
5964 text_data.SetName("some tex");
5965 AXTreeUpdate shorten_text_update;
5966 shorten_text_update.nodes = {text_data};
5967 ASSERT_TRUE(GetTree()->Unserialize(shorten_text_update));
5968
5969 EXPECT_FALSE(text_position->IsValid());
5970 text_position = text_position->AsValidPosition();
5971 EXPECT_TRUE(text_position->IsValid());
5972 EXPECT_EQ(8, text_position->text_offset());
5973
5974 // Now repeat the prior tests and ensure that we can create next character
5975 // positions with the new, valid MaxTextOffset (8).
5976 test_position = text_position->CreateNextCharacterPosition(
5977 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
5978 EXPECT_TRUE(test_position->IsValid());
5979 ASSERT_NE(nullptr, test_position);
5980 EXPECT_TRUE(test_position->IsTextPosition());
5981 EXPECT_EQ(text_data.id, test_position->anchor_id());
5982 EXPECT_EQ(8, test_position->text_offset());
5983 test_position = text_position->CreateNextCharacterPosition(
5984 AXBoundaryBehavior::CrossBoundary);
5985 ASSERT_NE(nullptr, test_position);
5986 EXPECT_TRUE(test_position->IsNullPosition());
5987
5988 // AsValidPosition should create a NullPosition if a position's anchor is
5989 // removed. This is true for both tree positions and text positions.
5990 EXPECT_TRUE(text_position->IsValid());
5991 TestPositionType tree_position = text_position->AsTreePosition();
5992 ASSERT_NE(nullptr, tree_position);
5993 EXPECT_TRUE(tree_position->IsTreePosition());
5994 EXPECT_TRUE(tree_position->IsValid());
5995 EXPECT_EQ(0, tree_position->child_index());
5996
5997 AXTreeUpdate remove_node_update;
5998 root_data.child_ids = {};
5999 remove_node_update.nodes = {root_data};
6000 ASSERT_TRUE(GetTree()->Unserialize(remove_node_update));
6001 EXPECT_FALSE(text_position->IsValid());
6002 EXPECT_FALSE(tree_position->IsValid());
6003
6004 text_position = text_position->AsValidPosition();
6005 EXPECT_TRUE(text_position->IsValid());
6006 tree_position = tree_position->AsValidPosition();
6007 EXPECT_TRUE(tree_position->IsValid());
6008
6009 EXPECT_TRUE(text_position->IsNullPosition());
6010 EXPECT_TRUE(tree_position->IsNullPosition());
6011}

References ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), CrossBoundary, ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXNodeData::SetName(), and StopIfAlreadyAtBoundary.

◆ TEST_F() [194/325]

ui::TEST_F ( AXPositionTest  ,
AsValidPositionInDescendantOfEmptyObject   
)

Definition at line 6013 of file ax_node_position_unittest.cc.

6013 {
6014 g_ax_embedded_object_behavior = AXEmbeddedObjectBehavior::kExposeCharacter;
6015
6016 // ++1 kRootWebArea
6017 // ++++2 kButton
6018 // ++++++3 kStaticText "3.14" ignored
6019 // ++++++++4 kInlineTextBox "3.14" ignored
6020 AXNodeData root_1;
6021 AXNodeData button_2;
6022 AXNodeData static_text_3;
6023 AXNodeData inline_box_4;
6024
6025 root_1.id = 1;
6026 button_2.id = 2;
6027 static_text_3.id = 3;
6028 inline_box_4.id = 4;
6029
6031 root_1.child_ids = {button_2.id};
6032
6033 button_2.role = ax::mojom::Role::kButton;
6034 button_2.child_ids = {static_text_3.id};
6035
6036 static_text_3.role = ax::mojom::Role::kStaticText;
6037 static_text_3.SetName("3.14");
6038 static_text_3.child_ids = {inline_box_4.id};
6039
6041 inline_box_4.SetName("3.14");
6042
6043 SetTree(CreateAXTree({root_1, button_2, static_text_3, inline_box_4}));
6044
6045 TestPositionType text_position = AXNodePosition::CreateTextPosition(
6046 GetTreeID(), inline_box_4.id, 3, ax::mojom::TextAffinity::kDownstream);
6047 ASSERT_NE(nullptr, text_position);
6048 EXPECT_TRUE(text_position->IsTextPosition());
6049 EXPECT_TRUE(text_position->IsValid());
6050 EXPECT_EQ(*text_position, *text_position->AsValidPosition());
6051
6052 TestPositionType tree_position =
6053 AXNodePosition::CreateTreePosition(GetTreeID(), inline_box_4.id, 0);
6054 ASSERT_NE(nullptr, tree_position);
6055 EXPECT_TRUE(tree_position->IsTreePosition());
6056 EXPECT_TRUE(tree_position->IsValid());
6057 EXPECT_EQ(*tree_position, *tree_position->AsValidPosition());
6058
6059 static_text_3.AddState(ax::mojom::State::kIgnored);
6061 AXTreeUpdate update;
6062 update.nodes = {static_text_3, inline_box_4};
6063 ASSERT_TRUE(GetTree()->Unserialize(update));
6064
6065 EXPECT_FALSE(text_position->IsValid());
6066 text_position = text_position->AsValidPosition();
6067 EXPECT_TRUE(text_position->IsValid());
6068 EXPECT_EQ(1, text_position->text_offset());
6069
6070 EXPECT_FALSE(tree_position->IsValid());
6071 tree_position = tree_position->AsValidPosition();
6072 EXPECT_TRUE(tree_position->IsValid());
6073 EXPECT_EQ(0, tree_position->child_index());
6074}
AXEmbeddedObjectBehavior g_ax_embedded_object_behavior

References ui::AXNodeData::AddState(), ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), g_ax_embedded_object_behavior, ui::AXNodeData::id, ax::mojom::kButton, ax::mojom::kDownstream, kExposeCharacter, ax::mojom::kIgnored, ax::mojom::kInlineTextBox, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ TEST_F() [195/325]

ui::TEST_F ( AXPositionTest  ,
AtEndOfAnchorWithNullPosition   
)

Definition at line 1197 of file ax_node_position_unittest.cc.

1197 {
1198 TestPositionType null_position = AXNodePosition::CreateNullPosition();
1199 ASSERT_NE(nullptr, null_position);
1200 EXPECT_FALSE(null_position->AtEndOfAnchor());
1201}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition().

◆ TEST_F() [196/325]

ui::TEST_F ( AXPositionTest  ,
AtEndOfAnchorWithTextPosition   
)

Definition at line 1220 of file ax_node_position_unittest.cc.

1220 {
1221 TestPositionType text_position = AXNodePosition::CreateTextPosition(
1222 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
1224 ASSERT_NE(nullptr, text_position);
1225 ASSERT_TRUE(text_position->IsTextPosition());
1226 EXPECT_TRUE(text_position->AtEndOfAnchor());
1227
1228 text_position = AXNodePosition::CreateTextPosition(
1229 GetTreeID(), inline_box1_.id, 5 /* text_offset */,
1231 ASSERT_NE(nullptr, text_position);
1232 ASSERT_TRUE(text_position->IsTextPosition());
1233 EXPECT_FALSE(text_position->AtEndOfAnchor());
1234
1235 text_position = AXNodePosition::CreateTextPosition(
1236 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
1238 ASSERT_NE(nullptr, text_position);
1239 ASSERT_TRUE(text_position->IsTextPosition());
1240 EXPECT_FALSE(text_position->AtEndOfAnchor());
1241}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ax::mojom::kDownstream, and ax::mojom::kUpstream.

◆ TEST_F() [197/325]

ui::TEST_F ( AXPositionTest  ,
AtEndOfAnchorWithTreePosition   
)

Definition at line 1203 of file ax_node_position_unittest.cc.

1203 {
1204 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
1205 GetTreeID(), root_.id, 3 /* child_index */);
1206 ASSERT_NE(nullptr, tree_position);
1207 EXPECT_TRUE(tree_position->AtEndOfAnchor());
1208
1209 tree_position = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
1210 2 /* child_index */);
1211 ASSERT_NE(nullptr, tree_position);
1212 EXPECT_FALSE(tree_position->AtEndOfAnchor());
1213
1214 tree_position = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
1215 0 /* child_index */);
1216 ASSERT_NE(nullptr, tree_position);
1217 EXPECT_FALSE(tree_position->AtEndOfAnchor());
1218}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition().

◆ TEST_F() [198/325]

ui::TEST_F ( AXPositionTest  ,
AtEndOfBlankLine   
)

Definition at line 1426 of file ax_node_position_unittest.cc.

1426 {
1427 // Modify the test tree so that the line break will appear on a line of its
1428 // own, i.e. as creating a blank line.
1429 inline_box1_.RemoveIntAttribute(ax::mojom::IntAttribute::kNextOnLineId);
1430 line_break_.RemoveIntAttribute(ax::mojom::IntAttribute::kPreviousOnLineId);
1431 AXTreeUpdate update;
1432 update.nodes = {inline_box1_, line_break_};
1433 ASSERT_TRUE(GetTree()->Unserialize(update));
1434
1435 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
1436 GetTreeID(), text_field_.id, 1 /* child_index */);
1437 ASSERT_NE(nullptr, tree_position);
1438 ASSERT_TRUE(tree_position->IsTreePosition());
1439 EXPECT_FALSE(tree_position->AtEndOfLine());
1440
1441 TestPositionType text_position = AXNodePosition::CreateTextPosition(
1442 GetTreeID(), line_break_.id, 0 /* text_offset */,
1444 ASSERT_NE(nullptr, text_position);
1445 ASSERT_TRUE(text_position->IsTextPosition());
1446 EXPECT_FALSE(text_position->AtEndOfLine());
1447
1448 text_position = AXNodePosition::CreateTextPosition(
1449 GetTreeID(), line_break_.id, 1 /* text_offset */,
1451 ASSERT_NE(nullptr, text_position);
1452 ASSERT_TRUE(text_position->IsTextPosition());
1453 EXPECT_TRUE(text_position->AtEndOfLine());
1454}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), ax::mojom::kDownstream, ax::mojom::kNextOnLineId, ax::mojom::kPreviousOnLineId, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes.

◆ TEST_F() [199/325]

ui::TEST_F ( AXPositionTest  ,
AtEndOfLineWithTextPosition   
)

Definition at line 1346 of file ax_node_position_unittest.cc.

1346 {
1347 TestPositionType text_position = AXNodePosition::CreateTextPosition(
1348 GetTreeID(), inline_box1_.id, 5 /* text_offset */,
1350 ASSERT_NE(nullptr, text_position);
1351 ASSERT_TRUE(text_position->IsTextPosition());
1352 EXPECT_FALSE(text_position->AtEndOfLine());
1353
1354 text_position = AXNodePosition::CreateTextPosition(
1355 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
1357 ASSERT_NE(nullptr, text_position);
1358 ASSERT_TRUE(text_position->IsTextPosition());
1359 EXPECT_TRUE(text_position->AtEndOfLine());
1360
1361 // A "before text" position anchored at the line break should visually be the
1362 // same as a text position at the end of the previous line.
1363 text_position = AXNodePosition::CreateTextPosition(
1364 GetTreeID(), line_break_.id, 0 /* text_offset */,
1366 ASSERT_NE(nullptr, text_position);
1367 ASSERT_TRUE(text_position->IsTextPosition());
1368 EXPECT_TRUE(text_position->AtEndOfLine());
1369
1370 // The following position comes after the soft line break, so it should not be
1371 // marked as the end of the line.
1372 text_position = AXNodePosition::CreateTextPosition(
1373 GetTreeID(), line_break_.id, 1 /* text_offset */,
1375 ASSERT_NE(nullptr, text_position);
1376 ASSERT_TRUE(text_position->IsTextPosition());
1377 EXPECT_FALSE(text_position->AtEndOfLine());
1378
1379 text_position = AXNodePosition::CreateTextPosition(
1380 GetTreeID(), inline_box2_.id, 5 /* text_offset */,
1382 ASSERT_NE(nullptr, text_position);
1383 ASSERT_TRUE(text_position->IsTextPosition());
1384 EXPECT_FALSE(text_position->AtEndOfLine());
1385
1386 text_position = AXNodePosition::CreateTextPosition(
1387 GetTreeID(), inline_box2_.id, 6 /* text_offset */,
1389 ASSERT_NE(nullptr, text_position);
1390 ASSERT_TRUE(text_position->IsTextPosition());
1391 EXPECT_TRUE(text_position->AtEndOfLine());
1392}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kDownstream.

◆ TEST_F() [200/325]

ui::TEST_F ( AXPositionTest  ,
AtEndOfParagraphWithTextPosition   
)

Definition at line 1800 of file ax_node_position_unittest.cc.

1800 {
1801 // End of |inline_box1_| is not the end of paragraph since it's
1802 // followed by a whitespace-only line breaking object
1803 TestPositionType text_position = AXNodePosition::CreateTextPosition(
1804 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
1806 ASSERT_NE(nullptr, text_position);
1807 ASSERT_TRUE(text_position->IsTextPosition());
1808 EXPECT_FALSE(text_position->AtEndOfParagraph());
1809
1810 // The start of |line_break_| is not the end of paragraph since it's
1811 // not the end of its anchor.
1812 text_position = AXNodePosition::CreateTextPosition(
1813 GetTreeID(), line_break_.id, 0 /* text_offset */,
1815 ASSERT_NE(nullptr, text_position);
1816 ASSERT_TRUE(text_position->IsTextPosition());
1817 EXPECT_FALSE(text_position->AtEndOfParagraph());
1818
1819 // The end of |line_break_| is the end of paragraph since it's
1820 // a line breaking object without additional trailing whitespace.
1821 text_position = AXNodePosition::CreateTextPosition(
1822 GetTreeID(), line_break_.id, 1 /* text_offset */,
1824 ASSERT_NE(nullptr, text_position);
1825 ASSERT_TRUE(text_position->IsTextPosition());
1826 EXPECT_TRUE(text_position->AtEndOfParagraph());
1827
1828 text_position = AXNodePosition::CreateTextPosition(
1829 GetTreeID(), inline_box2_.id, 5 /* text_offset */,
1831 ASSERT_NE(nullptr, text_position);
1832 ASSERT_TRUE(text_position->IsTextPosition());
1833 EXPECT_FALSE(text_position->AtEndOfParagraph());
1834
1835 // The end of |inline_box2_| is the end of paragraph since it's
1836 // followed by the end of document.
1837 text_position = AXNodePosition::CreateTextPosition(
1838 GetTreeID(), inline_box2_.id, 6 /* text_offset */,
1840 ASSERT_NE(nullptr, text_position);
1841 ASSERT_TRUE(text_position->IsTextPosition());
1842 EXPECT_TRUE(text_position->AtEndOfParagraph());
1843}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kDownstream.

◆ TEST_F() [201/325]

ui::TEST_F ( AXPositionTest  ,
AtLastNodeInTree   
)

Definition at line 5148 of file ax_node_position_unittest.cc.

5148 {
5149 TestPositionType text_position = AXNodePosition::CreateTextPosition(
5150 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
5152 ASSERT_NE(nullptr, text_position);
5153 EXPECT_FALSE(text_position->AtLastNodeInTree());
5154 EXPECT_FALSE(text_position->AsTreePosition()->AtLastNodeInTree());
5155
5156 TestPositionType test_position =
5157 text_position->CreatePositionAtEndOfDocument();
5158 ASSERT_NE(nullptr, test_position);
5159 EXPECT_TRUE(test_position->AtLastNodeInTree());
5160 EXPECT_TRUE(test_position->AsTreePosition()->AtLastNodeInTree());
5161 EXPECT_FALSE(text_position->CreateNullPosition()->AtLastNodeInTree());
5162
5163 TestPositionType on_last_node_but_not_at_maxtextoffset =
5164 AXNodePosition::CreateTextPosition(GetTreeID(), inline_box2_.id,
5165 1 /* text_offset */,
5167 ASSERT_NE(nullptr, on_last_node_but_not_at_maxtextoffset);
5168 EXPECT_TRUE(on_last_node_but_not_at_maxtextoffset->AtLastNodeInTree());
5169 EXPECT_TRUE(on_last_node_but_not_at_maxtextoffset->AsTreePosition()
5170 ->AtLastNodeInTree());
5171}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kDownstream.

◆ TEST_F() [202/325]

ui::TEST_F ( AXPositionTest  ,
AtStartAndEndOfLineInsideTextField   
)

Definition at line 1585 of file ax_node_position_unittest.cc.

1585 {
1586 // This test ensures that "AtStart/EndOfLine" methods work properly when at
1587 // the start or end of a text field.
1588 //
1589 // We set up a test tree with two text fields. The first one has one line of
1590 // text, and the second one three. There are inline text boxes containing only
1591 // white space at the start and end of both text fields, which is a valid
1592 // AXTree that might be generated by our renderer.
1593 AXNodeData root_data;
1594 root_data.id = 1;
1596 // "kIsLineBreakingObject" is not strictly necessary but is added for
1597 // completeness.
1599 true);
1600
1601 AXNodeData text_field_data_1;
1602 text_field_data_1.id = 2;
1603 text_field_data_1.role = ax::mojom::Role::kGroup;
1604 // "kIsLineBreakingObject" and the "kEditable" state are not strictly
1605 // necessary but are added for completeness.
1606 text_field_data_1.AddBoolAttribute(
1608 text_field_data_1.AddState(ax::mojom::State::kEditable);
1609 // Notice that there is one space at the start and one at the end of the text
1610 // field's value.
1611 text_field_data_1.SetValue(" Text field one ");
1612
1613 AXNodeData static_text_data_1;
1614 static_text_data_1.id = 3;
1615 static_text_data_1.role = ax::mojom::Role::kStaticText;
1616 static_text_data_1.SetName(" Text field one ");
1617
1618 AXNodeData inline_box_data_1;
1619 inline_box_data_1.id = 4;
1620 inline_box_data_1.role = ax::mojom::Role::kInlineTextBox;
1621 inline_box_data_1.SetName(" ");
1622
1623 AXNodeData inline_box_data_2;
1624 inline_box_data_2.id = 5;
1625 inline_box_data_2.role = ax::mojom::Role::kInlineTextBox;
1627 inline_box_data_2.id);
1629 inline_box_data_1.id);
1630 inline_box_data_2.SetName("Text field one");
1631
1632 AXNodeData inline_box_data_3;
1633 inline_box_data_3.id = 6;
1634 inline_box_data_3.role = ax::mojom::Role::kInlineTextBox;
1636 inline_box_data_3.id);
1638 inline_box_data_2.id);
1639 inline_box_data_3.SetName(" ");
1640
1641 AXNodeData text_field_data_2;
1642 text_field_data_2.id = 7;
1643 text_field_data_2.role = ax::mojom::Role::kGroup;
1644 // "kIsLineBreakingObject" and the "kEditable" state are not strictly
1645 // necessary but are added for completeness.
1646 text_field_data_2.AddBoolAttribute(
1648 text_field_data_1.AddState(ax::mojom::State::kEditable);
1649 // Notice that there are three lines, the first and the last one include only
1650 // a single space.
1651 text_field_data_2.SetValue(" Text field two ");
1652
1653 AXNodeData static_text_data_2;
1654 static_text_data_2.id = 8;
1655 static_text_data_2.role = ax::mojom::Role::kStaticText;
1656 static_text_data_2.SetName(" Text field two ");
1657
1658 AXNodeData inline_box_data_4;
1659 inline_box_data_4.id = 9;
1660 inline_box_data_4.role = ax::mojom::Role::kInlineTextBox;
1661 inline_box_data_4.SetName(" ");
1662
1663 AXNodeData inline_box_data_5;
1664 inline_box_data_5.id = 10;
1665 inline_box_data_5.role = ax::mojom::Role::kInlineTextBox;
1666 inline_box_data_5.SetName("Text field two");
1667
1668 AXNodeData inline_box_data_6;
1669 inline_box_data_6.id = 11;
1670 inline_box_data_6.role = ax::mojom::Role::kInlineTextBox;
1671 inline_box_data_6.SetName(" ");
1672
1673 static_text_data_1.child_ids = {inline_box_data_1.id, inline_box_data_2.id,
1674 inline_box_data_3.id};
1675 static_text_data_2.child_ids = {inline_box_data_4.id, inline_box_data_5.id,
1676 inline_box_data_6.id};
1677 text_field_data_1.child_ids = {static_text_data_1.id};
1678 text_field_data_2.child_ids = {static_text_data_2.id};
1679 root_data.child_ids = {text_field_data_1.id, text_field_data_2.id};
1680
1681 SetTree(
1682 CreateAXTree({root_data, text_field_data_1, static_text_data_1,
1683 inline_box_data_1, inline_box_data_2, inline_box_data_3,
1684 text_field_data_2, static_text_data_2, inline_box_data_4,
1685 inline_box_data_5, inline_box_data_6}));
1686
1687 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
1688 GetTreeID(), text_field_data_1.id, 0 /* child_index */);
1689 ASSERT_NE(nullptr, tree_position);
1690 ASSERT_TRUE(tree_position->IsTreePosition());
1691 EXPECT_TRUE(tree_position->AtStartOfLine());
1692 EXPECT_FALSE(tree_position->AtEndOfLine());
1693
1694 tree_position = AXNodePosition::CreateTreePosition(
1695 GetTreeID(), text_field_data_1.id, 1 /* child_index */);
1696 ASSERT_NE(nullptr, tree_position);
1697 ASSERT_TRUE(tree_position->IsTreePosition());
1698 EXPECT_FALSE(tree_position->AtStartOfLine());
1699 EXPECT_TRUE(tree_position->AtEndOfLine());
1700
1701 tree_position = AXNodePosition::CreateTreePosition(
1702 GetTreeID(), text_field_data_2.id, 0 /* child_index */);
1703 ASSERT_NE(nullptr, tree_position);
1704 ASSERT_TRUE(tree_position->IsTreePosition());
1705 EXPECT_TRUE(tree_position->AtStartOfLine());
1706 EXPECT_FALSE(tree_position->AtEndOfLine());
1707
1708 tree_position = AXNodePosition::CreateTreePosition(
1709 GetTreeID(), text_field_data_2.id, 1 /* child_index */);
1710 ASSERT_NE(nullptr, tree_position);
1711 ASSERT_TRUE(tree_position->IsTreePosition());
1712 EXPECT_FALSE(tree_position->AtStartOfLine());
1713 EXPECT_TRUE(tree_position->AtEndOfLine());
1714
1715 TestPositionType text_position = AXNodePosition::CreateTextPosition(
1716 GetTreeID(), text_field_data_1.id, 0 /* text_offset */,
1718 ASSERT_NE(nullptr, text_position);
1719 ASSERT_TRUE(text_position->IsTextPosition());
1720 EXPECT_TRUE(text_position->AtStartOfLine());
1721 EXPECT_FALSE(text_position->AtEndOfLine());
1722
1723 text_position = AXNodePosition::CreateTextPosition(
1724 GetTreeID(), text_field_data_1.id, 16 /* text_offset */,
1726 ASSERT_NE(nullptr, text_position);
1727 ASSERT_TRUE(text_position->IsTextPosition());
1728 EXPECT_FALSE(text_position->AtStartOfLine());
1729 EXPECT_TRUE(text_position->AtEndOfLine());
1730
1731 text_position = AXNodePosition::CreateTextPosition(
1732 GetTreeID(), text_field_data_2.id, 0 /* text_offset */,
1734 ASSERT_NE(nullptr, text_position);
1735 ASSERT_TRUE(text_position->IsTextPosition());
1736 EXPECT_TRUE(text_position->AtStartOfLine());
1737 EXPECT_FALSE(text_position->AtEndOfLine());
1738
1739 text_position = AXNodePosition::CreateTextPosition(
1740 GetTreeID(), text_field_data_2.id, 16 /* text_offset */,
1742 ASSERT_NE(nullptr, text_position);
1743 ASSERT_TRUE(text_position->IsTextPosition());
1744 EXPECT_FALSE(text_position->AtStartOfLine());
1745 EXPECT_TRUE(text_position->AtEndOfLine());
1746}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::AddIntAttribute(), ui::AXNodeData::AddState(), ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kEditable, ax::mojom::kGroup, ax::mojom::kInlineTextBox, ax::mojom::kIsLineBreakingObject, ax::mojom::kNextOnLineId, ax::mojom::kPreviousOnLineId, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXNodeData::role, ui::AXNodeData::SetName(), and ui::AXNodeData::SetValue().

◆ TEST_F() [203/325]

ui::TEST_F ( AXPositionTest  ,
AtStartAndEndOfLineWhenAtEndOfTextSpan   
)

Definition at line 1456 of file ax_node_position_unittest.cc.

1456 {
1457 // This test ensures that the "AtStartOfLine" and the "AtEndOfLine" methods
1458 // return false and true respectively when we are at the end of a text span.
1459 //
1460 // A text span is defined by a series of inline text boxes that make up a
1461 // single static text object. Lines always end at the end of static text
1462 // objects, so there would never arise a situation when a position at the end
1463 // of a text span would be at start of line. It should always be at end of
1464 // line. On the contrary, if a position is at the end of an inline text box
1465 // and the equivalent parent position is in the middle of a static text
1466 // object, then the position would sometimes be at start of line, i.e., when
1467 // the inline text box contains only white space that is used to separate
1468 // lines in the case of lines being wrapped by a soft line break.
1469 //
1470 // Example accessibility tree:
1471 // 0:kRootWebArea
1472 // ++1:kStaticText "Hello testing "
1473 // ++++2:kInlineTextBox "Hello" kNextOnLine=2
1474 // ++++3:kInlineTextBox " " kPreviousOnLine=2
1475 // ++++4:kInlineTextBox "testing" kNextOnLine=5
1476 // ++++5:kInlineTextBox " " kPreviousOnLine=4
1477 // ++6:kStaticText "here."
1478 // ++++7:kInlineTextBox "here."
1479 //
1480 // Resulting text representation:
1481 // "Hello<soft_line_break>testing <hard_line_break>here."
1482 // Notice the extra space after the word "testing". This is not a line break.
1483 // The hard line break is caused by the presence of the second static text
1484 // object.
1485 //
1486 // A position at the end of inline text box 3 should be at start of line,
1487 // whilst a position at the end of inline text box 5 should not.
1488
1489 AXNodeData root_data;
1490 root_data.id = 1;
1492 // "kIsLineBreakingObject" is not strictly necessary but is added for
1493 // completeness.
1495 true);
1496
1497 AXNodeData static_text_data_1;
1498 static_text_data_1.id = 2;
1499 static_text_data_1.role = ax::mojom::Role::kStaticText;
1500 static_text_data_1.SetName("Hello testing ");
1501
1502 AXNodeData inline_box_data_1;
1503 inline_box_data_1.id = 3;
1504 inline_box_data_1.role = ax::mojom::Role::kInlineTextBox;
1505 inline_box_data_1.SetName("hello");
1506
1507 AXNodeData inline_box_data_2;
1508 inline_box_data_2.id = 4;
1509 inline_box_data_2.role = ax::mojom::Role::kInlineTextBox;
1511 inline_box_data_2.id);
1513 inline_box_data_1.id);
1514 // The name is a space character that we assume it turns into a soft line
1515 // break by the layout engine.
1516 inline_box_data_2.SetName(" ");
1517
1518 AXNodeData inline_box_data_3;
1519 inline_box_data_3.id = 5;
1520 inline_box_data_3.role = ax::mojom::Role::kInlineTextBox;
1521 inline_box_data_3.SetName("testing");
1522
1523 AXNodeData inline_box_data_4;
1524 inline_box_data_4.id = 6;
1525 inline_box_data_4.role = ax::mojom::Role::kInlineTextBox;
1527 inline_box_data_4.id);
1529 inline_box_data_3.id);
1530 inline_box_data_4.SetName(" "); // Just a space character - not a line break.
1531
1532 AXNodeData static_text_data_2;
1533 static_text_data_2.id = 7;
1534 static_text_data_2.role = ax::mojom::Role::kStaticText;
1535 static_text_data_2.SetName("here.");
1536
1537 AXNodeData inline_box_data_5;
1538 inline_box_data_5.id = 8;
1539 inline_box_data_5.role = ax::mojom::Role::kInlineTextBox;
1540 inline_box_data_5.SetName("here.");
1541
1542 static_text_data_1.child_ids = {inline_box_data_1.id, inline_box_data_2.id,
1543 inline_box_data_3.id, inline_box_data_4.id};
1544 static_text_data_2.child_ids = {inline_box_data_5.id};
1545 root_data.child_ids = {static_text_data_1.id, static_text_data_2.id};
1546
1547 SetTree(CreateAXTree({root_data, static_text_data_1, inline_box_data_1,
1548 inline_box_data_2, inline_box_data_3, inline_box_data_4,
1549 static_text_data_2, inline_box_data_5}));
1550
1551 // An "after text" tree position - after the soft line break.
1552 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
1553 GetTreeID(), inline_box_data_2.id, 0 /* child_index */);
1554 ASSERT_NE(nullptr, tree_position);
1555 ASSERT_TRUE(tree_position->IsTreePosition());
1556 EXPECT_TRUE(tree_position->AtStartOfLine());
1557 EXPECT_FALSE(tree_position->AtEndOfLine());
1558
1559 // An "after text" tree position - after the space character and before the
1560 // hard line break caused by the second static text object.
1561 tree_position = AXNodePosition::CreateTreePosition(
1562 GetTreeID(), inline_box_data_4.id, 0 /* child_index */);
1563 ASSERT_NE(nullptr, tree_position);
1564 ASSERT_TRUE(tree_position->IsTreePosition());
1565 EXPECT_FALSE(tree_position->AtStartOfLine());
1566 EXPECT_TRUE(tree_position->AtEndOfLine());
1567
1568 TestPositionType text_position = AXNodePosition::CreateTextPosition(
1569 GetTreeID(), inline_box_data_2.id, 1 /* text_offset */,
1571 ASSERT_NE(nullptr, text_position);
1572 ASSERT_TRUE(text_position->IsTextPosition());
1573 EXPECT_TRUE(text_position->AtStartOfLine());
1574 EXPECT_FALSE(text_position->AtEndOfLine());
1575
1576 text_position = AXNodePosition::CreateTextPosition(
1577 GetTreeID(), inline_box_data_4.id, 1 /* text_offset */,
1579 ASSERT_NE(nullptr, text_position);
1580 ASSERT_TRUE(text_position->IsTextPosition());
1581 EXPECT_FALSE(text_position->AtStartOfLine());
1582 EXPECT_TRUE(text_position->AtEndOfLine());
1583}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::AddIntAttribute(), ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kInlineTextBox, ax::mojom::kIsLineBreakingObject, ax::mojom::kNextOnLineId, ax::mojom::kPreviousOnLineId, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ TEST_F() [204/325]

ui::TEST_F ( AXPositionTest  ,
AtStartOfAnchorWithNullPosition   
)

Definition at line 1139 of file ax_node_position_unittest.cc.

1139 {
1140 TestPositionType null_position = AXNodePosition::CreateNullPosition();
1141 ASSERT_NE(nullptr, null_position);
1142 EXPECT_FALSE(null_position->AtStartOfAnchor());
1143}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition().

◆ TEST_F() [205/325]

ui::TEST_F ( AXPositionTest  ,
AtStartOfAnchorWithTextPosition   
)

Definition at line 1174 of file ax_node_position_unittest.cc.

1174 {
1175 TestPositionType text_position = AXNodePosition::CreateTextPosition(
1176 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
1178 ASSERT_NE(nullptr, text_position);
1179 ASSERT_TRUE(text_position->IsTextPosition());
1180 EXPECT_TRUE(text_position->AtStartOfAnchor());
1181
1182 text_position = AXNodePosition::CreateTextPosition(
1183 GetTreeID(), inline_box1_.id, 1 /* text_offset */,
1185 ASSERT_NE(nullptr, text_position);
1186 ASSERT_TRUE(text_position->IsTextPosition());
1187 EXPECT_FALSE(text_position->AtStartOfAnchor());
1188
1189 text_position = AXNodePosition::CreateTextPosition(
1190 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
1192 ASSERT_NE(nullptr, text_position);
1193 ASSERT_TRUE(text_position->IsTextPosition());
1194 EXPECT_FALSE(text_position->AtStartOfAnchor());
1195}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ax::mojom::kDownstream, and ax::mojom::kUpstream.

◆ TEST_F() [206/325]

ui::TEST_F ( AXPositionTest  ,
AtStartOfAnchorWithTreePosition   
)

Definition at line 1145 of file ax_node_position_unittest.cc.

1145 {
1146 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
1147 GetTreeID(), root_.id, 0 /* child_index */);
1148 ASSERT_NE(nullptr, tree_position);
1149 EXPECT_TRUE(tree_position->AtStartOfAnchor());
1150
1151 tree_position = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
1152 1 /* child_index */);
1153 ASSERT_NE(nullptr, tree_position);
1154 EXPECT_FALSE(tree_position->AtStartOfAnchor());
1155
1156 tree_position = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
1157 3 /* child_index */);
1158 ASSERT_NE(nullptr, tree_position);
1159 EXPECT_FALSE(tree_position->AtStartOfAnchor());
1160
1161 // A "before text" position.
1162 tree_position = AXNodePosition::CreateTreePosition(
1163 GetTreeID(), inline_box1_.id, AXNodePosition::BEFORE_TEXT);
1164 ASSERT_NE(nullptr, tree_position);
1165 EXPECT_TRUE(tree_position->AtStartOfAnchor());
1166
1167 // An "after text" position.
1168 tree_position = AXNodePosition::CreateTreePosition(
1169 GetTreeID(), inline_box1_.id, 0 /* child_index */);
1170 ASSERT_NE(nullptr, tree_position);
1171 EXPECT_FALSE(tree_position->AtStartOfAnchor());
1172}

References ui::AXPosition< AXNodePosition, AXNode >::BEFORE_TEXT, and ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition().

◆ TEST_F() [207/325]

ui::TEST_F ( AXPositionTest  ,
AtStartOfBlankLine   
)

Definition at line 1394 of file ax_node_position_unittest.cc.

1394 {
1395 // Modify the test tree so that the line break will appear on a line of its
1396 // own, i.e. as creating a blank line.
1397 inline_box1_.RemoveIntAttribute(ax::mojom::IntAttribute::kNextOnLineId);
1398 line_break_.RemoveIntAttribute(ax::mojom::IntAttribute::kPreviousOnLineId);
1399 AXTreeUpdate update;
1400 update.nodes = {inline_box1_, line_break_};
1401 ASSERT_TRUE(GetTree()->Unserialize(update));
1402
1403 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
1404 GetTreeID(), text_field_.id, 1 /* child_index */);
1405 ASSERT_NE(nullptr, tree_position);
1406 ASSERT_TRUE(tree_position->IsTreePosition());
1407 EXPECT_TRUE(tree_position->AtStartOfLine());
1408
1409 TestPositionType text_position = AXNodePosition::CreateTextPosition(
1410 GetTreeID(), line_break_.id, 0 /* text_offset */,
1412 ASSERT_NE(nullptr, text_position);
1413 ASSERT_TRUE(text_position->IsTextPosition());
1414 EXPECT_TRUE(text_position->AtStartOfLine());
1415
1416 // A text position after a blank line should be equivalent to a "before text"
1417 // position at the line that comes after it.
1418 text_position = AXNodePosition::CreateTextPosition(
1419 GetTreeID(), line_break_.id, 1 /* text_offset */,
1421 ASSERT_NE(nullptr, text_position);
1422 ASSERT_TRUE(text_position->IsTextPosition());
1423 EXPECT_TRUE(text_position->AtStartOfLine());
1424}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), ax::mojom::kDownstream, ax::mojom::kNextOnLineId, ax::mojom::kPreviousOnLineId, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes.

◆ TEST_F() [208/325]

ui::TEST_F ( AXPositionTest  ,
AtStartOfLineStaticTextExtraPrecedingSpace   
)

Definition at line 1293 of file ax_node_position_unittest.cc.

1293 {
1294 // Consider the following web content:
1295 // <style>
1296 // .required-label::after {
1297 // content: " *";
1298 // }
1299 // </style>
1300 // <label class="required-label">Required </label>
1301 //
1302 // Which has the following AXTree, where the static text (#3)
1303 // contains an extra preceding space compared to its inline text (#4).
1304 // ++1 kRootWebArea
1305 // ++++2 kLabelText
1306 // ++++++3 kStaticText name=" *"
1307 // ++++++++4 kInlineTextBox name="*"
1308 // This test ensures that this difference between static text and its inline
1309 // text box does not cause a hang when AtStartOfLine is called on static text
1310 // with text position " <*>".
1311
1312 AXNodeData root;
1313 root.id = 1;
1315 // "kIsLineBreakingObject" is not strictly necessary but is added for
1316 // completeness.
1318 AXNodeData label_text;
1319 label_text.id = 2;
1320 label_text.role = ax::mojom::Role::kLabelText;
1321
1322 AXNodeData static_text1;
1323 static_text1.id = 3;
1324 static_text1.role = ax::mojom::Role::kStaticText;
1325 static_text1.SetName(" *");
1326
1327 AXNodeData inline_text1;
1328 inline_text1.id = 4;
1330 inline_text1.SetName("*");
1331
1332 static_text1.child_ids = {inline_text1.id};
1333 root.child_ids = {static_text1.id};
1334
1335 SetTree(CreateAXTree({root, static_text1, inline_text1}));
1336
1337 // Calling AtStartOfLine on |static_text1| with position " <*>",
1338 // text_offset_=1, should not get into an infinite loop; it should be
1339 // guaranteed to terminate.
1340 TestPositionType text_position = AXNodePosition::CreateTextPosition(
1341 GetTreeID(), static_text1.id, 1 /* child_index */,
1343 ASSERT_FALSE(text_position->AtStartOfLine());
1344}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kInlineTextBox, ax::mojom::kIsLineBreakingObject, ax::mojom::kLabelText, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ TEST_F() [209/325]

ui::TEST_F ( AXPositionTest  ,
AtStartOfLineWithTextPosition   
)

Definition at line 1243 of file ax_node_position_unittest.cc.

1243 {
1244 // An upstream affinity should not affect the outcome since there is no soft
1245 // line break.
1246 TestPositionType text_position = AXNodePosition::CreateTextPosition(
1247 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
1249 ASSERT_NE(nullptr, text_position);
1250 ASSERT_TRUE(text_position->IsTextPosition());
1251 EXPECT_TRUE(text_position->AtStartOfLine());
1252
1253 text_position = AXNodePosition::CreateTextPosition(
1254 GetTreeID(), inline_box1_.id, 1 /* text_offset */,
1256 ASSERT_NE(nullptr, text_position);
1257 ASSERT_TRUE(text_position->IsTextPosition());
1258 EXPECT_FALSE(text_position->AtStartOfLine());
1259
1260 text_position = AXNodePosition::CreateTextPosition(
1261 GetTreeID(), line_break_.id, 0 /* text_offset */,
1263 ASSERT_NE(nullptr, text_position);
1264 ASSERT_TRUE(text_position->IsTextPosition());
1265 EXPECT_FALSE(text_position->AtStartOfLine());
1266
1267 // An "after text" position anchored at the line break should be equivalent to
1268 // a "before text" position at the start of the next line.
1269 text_position = AXNodePosition::CreateTextPosition(
1270 GetTreeID(), line_break_.id, 1 /* text_offset */,
1272 ASSERT_NE(nullptr, text_position);
1273 ASSERT_TRUE(text_position->IsTextPosition());
1274 EXPECT_TRUE(text_position->AtStartOfLine());
1275
1276 // An upstream affinity should not affect the outcome since there is no soft
1277 // line break.
1278 text_position = AXNodePosition::CreateTextPosition(
1279 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
1281 ASSERT_NE(nullptr, text_position);
1282 ASSERT_TRUE(text_position->IsTextPosition());
1283 EXPECT_TRUE(text_position->AtStartOfLine());
1284
1285 text_position = AXNodePosition::CreateTextPosition(
1286 GetTreeID(), inline_box2_.id, 1 /* text_offset */,
1288 ASSERT_NE(nullptr, text_position);
1289 ASSERT_TRUE(text_position->IsTextPosition());
1290 EXPECT_FALSE(text_position->AtStartOfLine());
1291}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ax::mojom::kDownstream, and ax::mojom::kUpstream.

◆ TEST_F() [210/325]

ui::TEST_F ( AXPositionTest  ,
AtStartOfParagraphWithTextPosition   
)

Definition at line 1748 of file ax_node_position_unittest.cc.

1748 {
1749 // An upstream affinity should not affect the outcome since there is no soft
1750 // line break.
1751 TestPositionType text_position = AXNodePosition::CreateTextPosition(
1752 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
1754 ASSERT_NE(nullptr, text_position);
1755 ASSERT_TRUE(text_position->IsTextPosition());
1756 EXPECT_TRUE(text_position->AtStartOfParagraph());
1757
1758 text_position = AXNodePosition::CreateTextPosition(
1759 GetTreeID(), inline_box1_.id, 1 /* text_offset */,
1761 ASSERT_NE(nullptr, text_position);
1762 ASSERT_TRUE(text_position->IsTextPosition());
1763 EXPECT_FALSE(text_position->AtStartOfParagraph());
1764
1765 text_position = AXNodePosition::CreateTextPosition(
1766 GetTreeID(), line_break_.id, 0 /* text_offset */,
1768 ASSERT_NE(nullptr, text_position);
1769 ASSERT_TRUE(text_position->IsTextPosition());
1770 EXPECT_FALSE(text_position->AtStartOfParagraph());
1771
1772 // An "after text" position anchored at the line break should not be the same
1773 // as a text position at the start of the next paragraph because in practice
1774 // they should have resulted from two different ancestor positions. The former
1775 // should have been an upstream position, whilst the latter a downstream one.
1776 text_position = AXNodePosition::CreateTextPosition(
1777 GetTreeID(), line_break_.id, 1 /* text_offset */,
1779 ASSERT_NE(nullptr, text_position);
1780 ASSERT_TRUE(text_position->IsTextPosition());
1781 EXPECT_FALSE(text_position->AtStartOfParagraph());
1782
1783 // An upstream affinity should not affect the outcome since there is no soft
1784 // line break.
1785 text_position = AXNodePosition::CreateTextPosition(
1786 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
1788 ASSERT_NE(nullptr, text_position);
1789 ASSERT_TRUE(text_position->IsTextPosition());
1790 EXPECT_TRUE(text_position->AtStartOfParagraph());
1791
1792 text_position = AXNodePosition::CreateTextPosition(
1793 GetTreeID(), inline_box2_.id, 1 /* text_offset */,
1795 ASSERT_NE(nullptr, text_position);
1796 ASSERT_TRUE(text_position->IsTextPosition());
1797 EXPECT_FALSE(text_position->AtStartOfParagraph());
1798}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ax::mojom::kDownstream, and ax::mojom::kUpstream.

◆ TEST_F() [211/325]

ui::TEST_F ( AXPositionTest  ,
AtStartOrEndOfParagraphOnAListMarker   
)

Definition at line 2057 of file ax_node_position_unittest.cc.

2057 {
2058 // "AtStartOfParagraph" should return true before a list marker, either a
2059 // Legacy Layout or an NG Layout one. It should return false on the next
2060 // sibling of the list marker, i.e., before the list item's actual text
2061 // contents.
2062 //
2063 // There are two list markers in the following test tree. The first one is a
2064 // Legacy Layout one and the second an NG Layout one.
2065 // ++1 kRootWebArea
2066 // ++++2 kStaticText "Before list."
2067 // ++++++3 kInlineTextBox "Before list."
2068 // ++++4 kList
2069 // ++++++5 kListItem
2070 // ++++++++6 kListMarker
2071 // ++++++++++7 kStaticText "1. "
2072 // ++++++++++++8 kInlineTextBox "1. "
2073 // ++++++++9 kStaticText "First item."
2074 // ++++++++++10 kInlineTextBox "First item."
2075 // ++++++11 kListItem
2076 // ++++++++12 kListMarker "2. "
2077 // ++++++++13 kStaticText "Second item."
2078 // ++++++++++14 kInlineTextBox "Second item."
2079 // ++15 kStaticText "After list."
2080 // ++++16 kInlineTextBox "After list."
2081
2082 AXNodeData root;
2083 AXNodeData list;
2084 AXNodeData list_item1;
2085 AXNodeData list_item2;
2086 AXNodeData list_marker_legacy;
2087 AXNodeData list_marker_ng;
2088 AXNodeData static_text1;
2089 AXNodeData static_text2;
2090 AXNodeData static_text3;
2091 AXNodeData static_text4;
2092 AXNodeData static_text5;
2093 AXNodeData inline_box1;
2094 AXNodeData inline_box2;
2095 AXNodeData inline_box3;
2096 AXNodeData inline_box4;
2097 AXNodeData inline_box5;
2098
2099 root.id = 1;
2100 static_text1.id = 2;
2101 inline_box1.id = 3;
2102 list.id = 4;
2103 list_item1.id = 5;
2104 list_marker_legacy.id = 6;
2105 static_text2.id = 7;
2106 inline_box2.id = 8;
2107 static_text3.id = 9;
2108 inline_box3.id = 10;
2109 list_item2.id = 11;
2110 list_marker_ng.id = 12;
2111 static_text4.id = 13;
2112 inline_box4.id = 14;
2113 static_text5.id = 15;
2114 inline_box5.id = 16;
2115
2117 root.child_ids = {static_text1.id, list.id, static_text5.id};
2119
2120 static_text1.role = ax::mojom::Role::kStaticText;
2121 static_text1.child_ids = {inline_box1.id};
2122 static_text1.SetName("Before list.");
2123
2125 inline_box1.SetName("Before list.");
2126
2128 list.child_ids = {list_item1.id, list_item2.id};
2129
2130 list_item1.role = ax::mojom::Role::kListItem;
2131 list_item1.child_ids = {list_marker_legacy.id, static_text3.id};
2133 true);
2134
2135 list_marker_legacy.role = ax::mojom::Role::kListMarker;
2136 list_marker_legacy.child_ids = {static_text2.id};
2137
2138 static_text2.role = ax::mojom::Role::kStaticText;
2139 static_text2.child_ids = {inline_box2.id};
2140 static_text2.SetName("1. ");
2141
2143 inline_box2.SetName("1. ");
2145 inline_box3.id);
2146
2147 static_text3.role = ax::mojom::Role::kStaticText;
2148 static_text3.child_ids = {inline_box3.id};
2149 static_text3.SetName("First item.");
2150
2152 inline_box3.SetName("First item.");
2154 inline_box2.id);
2155
2156 list_item2.role = ax::mojom::Role::kListItem;
2157 list_item2.child_ids = {list_marker_ng.id, static_text4.id};
2159 true);
2160
2161 list_marker_ng.role = ax::mojom::Role::kListMarker;
2162 list_marker_ng.SetName("2. ");
2164 inline_box4.id);
2165
2166 static_text4.role = ax::mojom::Role::kStaticText;
2167 static_text4.child_ids = {inline_box4.id};
2168 static_text4.SetName("Second item.");
2169
2171 inline_box4.SetName("Second item.");
2173 list_marker_ng.id);
2174
2175 static_text5.role = ax::mojom::Role::kStaticText;
2176 static_text5.child_ids = {inline_box5.id};
2177 static_text5.SetName("After list.");
2178
2180 inline_box5.SetName("After list.");
2181
2182 SetTree(CreateAXTree({root, static_text1, inline_box1, list, list_item1,
2183 list_marker_legacy, static_text2, inline_box2,
2184 static_text3, inline_box3, list_item2, list_marker_ng,
2185 static_text4, inline_box4, static_text5, inline_box5}));
2186
2187 // A text position after the text "Before list.". It should not be equivalent
2188 // to a position that is before the list itself, or before the first list
2189 // bullet / item.
2190 TestPositionType text_position = AXNodePosition::CreateTextPosition(
2191 GetTreeID(), static_text1.id, 12 /* text_offset */,
2193 ASSERT_NE(nullptr, text_position);
2194 EXPECT_FALSE(text_position->AtStartOfParagraph());
2195 EXPECT_TRUE(text_position->AtEndOfParagraph());
2196
2197 // A text position after the text "Before list.". It should not be equivalent
2198 // to a position that is before the list itself, or before the first list
2199 // bullet / item.
2200 text_position = AXNodePosition::CreateTextPosition(
2201 GetTreeID(), inline_box1.id, 12 /* text_offset */,
2203 ASSERT_NE(nullptr, text_position);
2204 EXPECT_FALSE(text_position->AtStartOfParagraph());
2205 EXPECT_TRUE(text_position->AtEndOfParagraph());
2206
2207 // A text position before the list.
2208 text_position = AXNodePosition::CreateTextPosition(
2209 GetTreeID(), list.id, 0 /* text_offset */,
2211 ASSERT_NE(nullptr, text_position);
2212 EXPECT_TRUE(text_position->AtStartOfParagraph());
2213 EXPECT_FALSE(text_position->AtEndOfParagraph());
2214
2215 // A downstream text position after the list. It should resolve to a leaf
2216 // position before the paragraph that comes after the list, so it should be
2217 // "AtStartOfParagraph".
2218 text_position = AXNodePosition::CreateTextPosition(
2219 GetTreeID(), list.id, 14 /* text_offset */,
2221 ASSERT_NE(nullptr, text_position);
2222 EXPECT_TRUE(text_position->AtStartOfParagraph());
2223 EXPECT_FALSE(text_position->AtEndOfParagraph());
2224
2225 // An upstream text position after the list. It should be "AtEndOfParagraph".
2226 text_position = AXNodePosition::CreateTextPosition(
2227 GetTreeID(), list.id, 14 /* text_offset */,
2229 ASSERT_NE(nullptr, text_position);
2230 EXPECT_FALSE(text_position->AtStartOfParagraph());
2231 EXPECT_TRUE(text_position->AtEndOfParagraph());
2232
2233 // A text position before the first list bullet (the Legacy Layout one).
2234 text_position = AXNodePosition::CreateTextPosition(
2235 GetTreeID(), list_marker_legacy.id, 0 /* text_offset */,
2237 ASSERT_NE(nullptr, text_position);
2238 EXPECT_TRUE(text_position->AtStartOfParagraph());
2239 EXPECT_FALSE(text_position->AtEndOfParagraph());
2240
2241 text_position = AXNodePosition::CreateTextPosition(
2242 GetTreeID(), list_marker_legacy.id, 1 /* text_offset */,
2244 ASSERT_NE(nullptr, text_position);
2245 EXPECT_FALSE(text_position->AtStartOfParagraph());
2246 EXPECT_FALSE(text_position->AtEndOfParagraph());
2247
2248 // A text position before the first list bullet (the Legacy Layout one).
2249 text_position = AXNodePosition::CreateTextPosition(
2250 GetTreeID(), static_text2.id, 0 /* text_offset */,
2252 ASSERT_NE(nullptr, text_position);
2253 EXPECT_TRUE(text_position->AtStartOfParagraph());
2254 EXPECT_FALSE(text_position->AtEndOfParagraph());
2255
2256 text_position = AXNodePosition::CreateTextPosition(
2257 GetTreeID(), static_text2.id, 2 /* text_offset */,
2259 ASSERT_NE(nullptr, text_position);
2260 EXPECT_FALSE(text_position->AtStartOfParagraph());
2261 EXPECT_FALSE(text_position->AtEndOfParagraph());
2262
2263 // A text position before the first list bullet (the Legacy Layout one).
2264 text_position = AXNodePosition::CreateTextPosition(
2265 GetTreeID(), inline_box2.id, 0 /* text_offset */,
2267 ASSERT_NE(nullptr, text_position);
2268 EXPECT_TRUE(text_position->AtStartOfParagraph());
2269 EXPECT_FALSE(text_position->AtEndOfParagraph());
2270
2271 text_position = AXNodePosition::CreateTextPosition(
2272 GetTreeID(), inline_box2.id, 3 /* text_offset */,
2274 ASSERT_NE(nullptr, text_position);
2275 EXPECT_FALSE(text_position->AtStartOfParagraph());
2276 EXPECT_FALSE(text_position->AtEndOfParagraph());
2277
2278 // A text position before the second list bullet (the NG Layout one).
2279 text_position = AXNodePosition::CreateTextPosition(
2280 GetTreeID(), list_marker_ng.id, 0 /* text_offset */,
2282 ASSERT_NE(nullptr, text_position);
2283 EXPECT_TRUE(text_position->AtStartOfParagraph());
2284 EXPECT_FALSE(text_position->AtEndOfParagraph());
2285
2286 text_position = AXNodePosition::CreateTextPosition(
2287 GetTreeID(), list_marker_ng.id, 3 /* text_offset */,
2289 ASSERT_NE(nullptr, text_position);
2290 EXPECT_FALSE(text_position->AtStartOfParagraph());
2291 EXPECT_FALSE(text_position->AtEndOfParagraph());
2292
2293 // A text position before the text contents of the first list item - not the
2294 // bullet.
2295 text_position = AXNodePosition::CreateTextPosition(
2296 GetTreeID(), static_text3.id, 0 /* text_offset */,
2298 ASSERT_NE(nullptr, text_position);
2299 EXPECT_FALSE(text_position->AtStartOfParagraph());
2300 EXPECT_FALSE(text_position->AtEndOfParagraph());
2301
2302 // A text position before the text contents of the first list item - not the
2303 // bullet.
2304 text_position = AXNodePosition::CreateTextPosition(
2305 GetTreeID(), inline_box3.id, 0 /* text_offset */,
2307 ASSERT_NE(nullptr, text_position);
2308 EXPECT_FALSE(text_position->AtStartOfParagraph());
2309 EXPECT_FALSE(text_position->AtEndOfParagraph());
2310
2311 // A text position after the text contents of the first list item.
2312 text_position = AXNodePosition::CreateTextPosition(
2313 GetTreeID(), static_text3.id, 11 /* text_offset */,
2315 ASSERT_NE(nullptr, text_position);
2316 EXPECT_FALSE(text_position->AtStartOfParagraph());
2317 EXPECT_TRUE(text_position->AtEndOfParagraph());
2318
2319 // A text position after the text contents of the first list item.
2320 text_position = AXNodePosition::CreateTextPosition(
2321 GetTreeID(), inline_box3.id, 11 /* text_offset */,
2323 ASSERT_NE(nullptr, text_position);
2324 EXPECT_FALSE(text_position->AtStartOfParagraph());
2325 EXPECT_TRUE(text_position->AtEndOfParagraph());
2326
2327 // A text position before the text contents of the second list item - not the
2328 // bullet.
2329 text_position = AXNodePosition::CreateTextPosition(
2330 GetTreeID(), static_text4.id, 0 /* text_offset */,
2332 ASSERT_NE(nullptr, text_position);
2333 EXPECT_FALSE(text_position->AtStartOfParagraph());
2334 EXPECT_FALSE(text_position->AtEndOfParagraph());
2335
2336 // A text position before the text contents of the second list item - not the
2337 // bullet.
2338 text_position = AXNodePosition::CreateTextPosition(
2339 GetTreeID(), inline_box4.id, 0 /* text_offset */,
2341 ASSERT_NE(nullptr, text_position);
2342 EXPECT_FALSE(text_position->AtStartOfParagraph());
2343 EXPECT_FALSE(text_position->AtEndOfParagraph());
2344
2345 // A text position after the text contents of the second list item.
2346 text_position = AXNodePosition::CreateTextPosition(
2347 GetTreeID(), static_text4.id, 12 /* text_offset */,
2349 ASSERT_NE(nullptr, text_position);
2350 EXPECT_FALSE(text_position->AtStartOfParagraph());
2351 EXPECT_TRUE(text_position->AtEndOfParagraph());
2352
2353 // A text position after the text contents of the second list item.
2354 text_position = AXNodePosition::CreateTextPosition(
2355 GetTreeID(), inline_box4.id, 12 /* text_offset */,
2357 ASSERT_NE(nullptr, text_position);
2358 EXPECT_FALSE(text_position->AtStartOfParagraph());
2359 EXPECT_TRUE(text_position->AtEndOfParagraph());
2360
2361 // A text position before the text "After list.".
2362 text_position = AXNodePosition::CreateTextPosition(
2363 GetTreeID(), inline_box5.id, 0 /* text_offset */,
2365 ASSERT_NE(nullptr, text_position);
2366 EXPECT_TRUE(text_position->AtStartOfParagraph());
2367 EXPECT_FALSE(text_position->AtEndOfParagraph());
2368}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::AddIntAttribute(), ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kInlineTextBox, ax::mojom::kIsLineBreakingObject, ax::mojom::kList, ax::mojom::kListItem, ax::mojom::kListMarker, ax::mojom::kNextOnLineId, ax::mojom::kPreviousOnLineId, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ax::mojom::kUpstream, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ TEST_F() [212/325]

ui::TEST_F ( AXPositionTest  ,
AtStartOrEndOfParagraphWithEmbeddedObjectCharacter   
)

Definition at line 2734 of file ax_node_position_unittest.cc.

2734 {
2735 g_ax_embedded_object_behavior = AXEmbeddedObjectBehavior::kExposeCharacter;
2736
2737 // This test ensures that "At{Start|End}OfParagraph" work correctly when there
2738 // are embedded objects present near a paragraph boundary.
2739 //
2740 // Nodes represented by an embedded object character, such as a plain text
2741 // field or a check box, should create an implicit paragraph boundary for
2742 // assistive software.
2743 // ++1 kRootWebArea isLineBreakingObject
2744 // ++++2 kLink
2745 // ++++++3 kStaticText "hello"
2746 // ++++++++4 kInlineTextBox "hello"
2747 // ++++++5 kImage
2748 // ++++++6 kStaticText "world"
2749 // ++++++++7 kInlineTextBox "world"
2750
2751 AXNodeData root_1;
2752 AXNodeData link_2;
2753 AXNodeData static_text_3;
2754 AXNodeData inline_box_4;
2755 AXNodeData image_5;
2756 AXNodeData static_text_6;
2757 AXNodeData inline_box_7;
2758
2759 root_1.id = 1;
2760 link_2.id = 2;
2761 static_text_3.id = 3;
2762 inline_box_4.id = 4;
2763 image_5.id = 5;
2764 static_text_6.id = 6;
2765 inline_box_7.id = 7;
2766
2768 root_1.child_ids = {link_2.id};
2770 true);
2771
2773 link_2.child_ids = {static_text_3.id, image_5.id, static_text_6.id};
2774
2775 static_text_3.role = ax::mojom::Role::kStaticText;
2776 static_text_3.child_ids = {inline_box_4.id};
2777 static_text_3.SetName("Hello");
2778
2780 inline_box_4.SetName("Hello");
2781
2782 image_5.role = ax::mojom::Role::kImage;
2783 // The image's inner text should be an embedded object character.
2784
2785 static_text_6.role = ax::mojom::Role::kStaticText;
2786 static_text_6.child_ids = {inline_box_7.id};
2787 static_text_6.SetName("world");
2788
2790 inline_box_7.SetName("world");
2791
2792 SetTree(CreateAXTree({root_1, link_2, static_text_3, inline_box_4, image_5,
2793 static_text_6, inline_box_7}));
2794
2795 // Before "hello".
2796 TestPositionType text_position = AXNodePosition::CreateTextPosition(
2797 GetTreeID(), inline_box_4.id, 0 /* text_offset */,
2799 EXPECT_FALSE(text_position->AtEndOfParagraph());
2800 EXPECT_TRUE(text_position->AtStartOfParagraph());
2801
2802 // After "hello".
2803 //
2804 // Note that even though this position and a position before the image's
2805 // embedded object character are conceptually equivalent, in practice they
2806 // should result from two different ancestor positions. The former should have
2807 // been an upstream position, whilst the latter a downstream one.
2808 text_position = AXNodePosition::CreateTextPosition(
2809 GetTreeID(), inline_box_4.id, 5 /* text_offset */,
2811 EXPECT_TRUE(text_position->AtEndOfParagraph());
2812 EXPECT_FALSE(text_position->AtStartOfParagraph());
2813
2814 // Before the image's embedded object character.
2815 text_position = AXNodePosition::CreateTextPosition(
2816 GetTreeID(), image_5.id, 0 /* text_offset */,
2818 EXPECT_FALSE(text_position->AtEndOfParagraph());
2819 EXPECT_TRUE(text_position->AtStartOfParagraph());
2820
2821 // After the image's embedded object character.
2822 text_position = AXNodePosition::CreateTextPosition(
2823 GetTreeID(), image_5.id, 1 /* text_offset */,
2825 EXPECT_TRUE(text_position->AtEndOfParagraph());
2826 EXPECT_FALSE(text_position->AtStartOfParagraph());
2827
2828 // Before "world".
2829 text_position = AXNodePosition::CreateTextPosition(
2830 GetTreeID(), inline_box_7.id, 0 /* text_offset */,
2832 EXPECT_FALSE(text_position->AtEndOfParagraph());
2833 EXPECT_TRUE(text_position->AtStartOfParagraph());
2834
2835 // After "world".
2836 text_position = AXNodePosition::CreateTextPosition(
2837 GetTreeID(), inline_box_7.id, 5 /* text_offset */,
2839 EXPECT_TRUE(text_position->AtEndOfParagraph());
2840 EXPECT_FALSE(text_position->AtStartOfParagraph());
2841}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), g_ax_embedded_object_behavior, ui::AXNodeData::id, ax::mojom::kDownstream, kExposeCharacter, ax::mojom::kImage, ax::mojom::kInlineTextBox, ax::mojom::kIsLineBreakingObject, ax::mojom::kLink, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ TEST_F() [213/325]

ui::TEST_F ( AXPositionTest  ,
AtStartOrEndOfParagraphWithIgnoredNodes   
)

Definition at line 2551 of file ax_node_position_unittest.cc.

2551 {
2552 // This test ensures that "At{Start|End}OfParagraph" work correctly when there
2553 // are ignored nodes present near a paragraph boundary.
2554 //
2555 // An ignored node that is between a given position and a paragraph boundary
2556 // should not be taken into consideration. The position should be interpreted
2557 // as being on the boundary.
2558 // ++1 kRootWebArea isLineBreakingObject
2559 // ++++2 kGenericContainer ignored isLineBreakingObject
2560 // ++++++3 kStaticText ignored "ignored text"
2561 // ++++++++4 kInlineTextBox ignored "ignored text"
2562 // ++++5 kGenericContainer isLineBreakingObject
2563 // ++++++6 kStaticText "some text"
2564 // ++++++++7 kInlineTextBox "some"
2565 // ++++++++8 kInlineTextBox " "
2566 // ++++++++9 kInlineTextBox "text"
2567 // ++++10 kGenericContainer ignored isLineBreakingObject
2568 // ++++++11 kStaticText ignored "ignored text"
2569 // ++++++++12 kInlineTextBox ignored "ignored text"
2570
2571 AXNodeData root_data;
2572 root_data.id = 1;
2575 true);
2576
2577 AXNodeData container_data_a;
2578 container_data_a.id = 2;
2579 container_data_a.role = ax::mojom::Role::kGenericContainer;
2580 container_data_a.AddState(ax::mojom::State::kIgnored);
2581 container_data_a.AddBoolAttribute(
2583
2584 AXNodeData static_text_data_a;
2585 static_text_data_a.id = 3;
2586 static_text_data_a.role = ax::mojom::Role::kStaticText;
2587 static_text_data_a.SetName("ignored text");
2588 static_text_data_a.AddState(ax::mojom::State::kIgnored);
2589
2590 AXNodeData inline_text_data_a;
2591 inline_text_data_a.id = 4;
2592 inline_text_data_a.role = ax::mojom::Role::kInlineTextBox;
2593 inline_text_data_a.SetName("ignored text");
2594 inline_text_data_a.AddState(ax::mojom::State::kIgnored);
2595
2596 AXNodeData container_data_b;
2597 container_data_b.id = 5;
2598 container_data_b.role = ax::mojom::Role::kGenericContainer;
2599 container_data_b.AddBoolAttribute(
2601
2602 AXNodeData static_text_data_b;
2603 static_text_data_b.id = 6;
2604 static_text_data_b.role = ax::mojom::Role::kStaticText;
2605 static_text_data_b.SetName("some text");
2606
2607 AXNodeData inline_text_data_b_1;
2608 inline_text_data_b_1.id = 7;
2609 inline_text_data_b_1.role = ax::mojom::Role::kInlineTextBox;
2610 inline_text_data_b_1.SetName("some");
2611
2612 AXNodeData inline_text_data_b_2;
2613 inline_text_data_b_2.id = 8;
2614 inline_text_data_b_2.role = ax::mojom::Role::kInlineTextBox;
2615 inline_text_data_b_2.SetName(" ");
2616
2617 AXNodeData inline_text_data_b_3;
2618 inline_text_data_b_3.id = 9;
2619 inline_text_data_b_3.role = ax::mojom::Role::kInlineTextBox;
2620 inline_text_data_b_3.SetName("text");
2621
2622 AXNodeData container_data_c;
2623 container_data_c.id = 10;
2624 container_data_c.role = ax::mojom::Role::kGenericContainer;
2625 container_data_c.AddState(ax::mojom::State::kIgnored);
2626 container_data_c.AddBoolAttribute(
2628
2629 AXNodeData static_text_data_c;
2630 static_text_data_c.id = 11;
2631 static_text_data_c.role = ax::mojom::Role::kStaticText;
2632 static_text_data_c.SetName("ignored text");
2633 static_text_data_c.AddState(ax::mojom::State::kIgnored);
2634
2635 AXNodeData inline_text_data_c;
2636 inline_text_data_c.id = 12;
2637 inline_text_data_c.role = ax::mojom::Role::kInlineTextBox;
2638 inline_text_data_c.SetName("ignored text");
2639 inline_text_data_c.AddState(ax::mojom::State::kIgnored);
2640
2641 root_data.child_ids = {container_data_a.id, container_data_b.id,
2642 container_data_c.id};
2643 container_data_a.child_ids = {static_text_data_a.id};
2644 static_text_data_a.child_ids = {inline_text_data_a.id};
2645 container_data_b.child_ids = {static_text_data_b.id};
2646 static_text_data_b.child_ids = {inline_text_data_b_1.id,
2647 inline_text_data_b_2.id,
2648 inline_text_data_b_3.id};
2649 container_data_c.child_ids = {static_text_data_c.id};
2650 static_text_data_c.child_ids = {inline_text_data_c.id};
2651
2652 SetTree(CreateAXTree(
2653 {root_data, container_data_a, container_data_b, container_data_c,
2654 static_text_data_a, static_text_data_b, static_text_data_c,
2655 inline_text_data_a, inline_text_data_b_1, inline_text_data_b_2,
2656 inline_text_data_b_3, inline_text_data_c}));
2657
2658 // Before "ignored text".
2659 TestPositionType text_position1 = AXNodePosition::CreateTextPosition(
2660 GetTreeID(), inline_text_data_a.id, 0 /* text_offset */,
2662 EXPECT_FALSE(text_position1->AtEndOfParagraph());
2663 EXPECT_FALSE(text_position1->AtStartOfParagraph());
2664
2665 // After "ignored text".
2666 //
2667 // Since the position is an "after text" position, it is similar to pressing
2668 // the End key, (or Cmd-Right on Mac), while the caret is on "ignored text",
2669 // so it should not be "AtStartOfParagraph". In practice, this situation
2670 // should not arise in accessibility, because the node is ignored.
2671 TestPositionType text_position2 = AXNodePosition::CreateTextPosition(
2672 GetTreeID(), inline_text_data_a.id, 12 /* text_offset */,
2674 EXPECT_FALSE(text_position2->AtEndOfParagraph());
2675 EXPECT_FALSE(text_position2->AtStartOfParagraph());
2676
2677 // Before "some".
2678 TestPositionType text_position3 = AXNodePosition::CreateTextPosition(
2679 GetTreeID(), inline_text_data_b_1.id, 0 /* text_offset */,
2681 EXPECT_FALSE(text_position3->AtEndOfParagraph());
2682 EXPECT_TRUE(text_position3->AtStartOfParagraph());
2683
2684 // After "some".
2685 TestPositionType text_position4 = AXNodePosition::CreateTextPosition(
2686 GetTreeID(), inline_text_data_b_1.id, 4 /* text_offset */,
2688 EXPECT_FALSE(text_position4->AtEndOfParagraph());
2689 EXPECT_FALSE(text_position4->AtStartOfParagraph());
2690
2691 // Before " ".
2692 TestPositionType text_position5 = AXNodePosition::CreateTextPosition(
2693 GetTreeID(), inline_text_data_b_2.id, 0 /* text_offset */,
2695 EXPECT_FALSE(text_position5->AtEndOfParagraph());
2696 EXPECT_FALSE(text_position5->AtStartOfParagraph());
2697
2698 // After " ".
2699 TestPositionType text_position6 = AXNodePosition::CreateTextPosition(
2700 GetTreeID(), inline_text_data_b_2.id, 1 /* text_offset */,
2702 EXPECT_FALSE(text_position6->AtEndOfParagraph());
2703 EXPECT_FALSE(text_position6->AtStartOfParagraph());
2704
2705 // Before "text".
2706 TestPositionType text_position7 = AXNodePosition::CreateTextPosition(
2707 GetTreeID(), inline_text_data_b_3.id, 0 /* text_offset */,
2709 EXPECT_FALSE(text_position7->AtEndOfParagraph());
2710 EXPECT_FALSE(text_position7->AtStartOfParagraph());
2711
2712 // After "text".
2713 TestPositionType text_position8 = AXNodePosition::CreateTextPosition(
2714 GetTreeID(), inline_text_data_b_3.id, 4 /* text_offset */,
2716 EXPECT_TRUE(text_position8->AtEndOfParagraph());
2717 EXPECT_FALSE(text_position8->AtStartOfParagraph());
2718
2719 // Before "ignored text" - the second version.
2720 TestPositionType text_position9 = AXNodePosition::CreateTextPosition(
2721 GetTreeID(), inline_text_data_c.id, 0 /* text_offset */,
2723 EXPECT_FALSE(text_position9->AtEndOfParagraph());
2724 EXPECT_FALSE(text_position9->AtStartOfParagraph());
2725
2726 // After "ignored text" - the second version.
2727 TestPositionType text_position10 = AXNodePosition::CreateTextPosition(
2728 GetTreeID(), inline_text_data_c.id, 12 /* text_offset */,
2730 EXPECT_FALSE(text_position10->AtEndOfParagraph());
2731 EXPECT_FALSE(text_position10->AtStartOfParagraph());
2732}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::AddState(), ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kGenericContainer, ax::mojom::kIgnored, ax::mojom::kInlineTextBox, ax::mojom::kIsLineBreakingObject, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ TEST_F() [214/325]

ui::TEST_F ( AXPositionTest  ,
AtStartOrEndOfParagraphWithLeadingAndTrailingDocumentWhitespace   
)

Definition at line 2370 of file ax_node_position_unittest.cc.

2371 {
2372 // This test ensures that "At{Start|End}OfParagraph" work correctly when a
2373 // text position is on a preserved newline character.
2374 //
2375 // Newline characters are used to separate paragraphs. If there is a series of
2376 // newline characters, a paragraph should start after the last newline
2377 // character.
2378 // ++1 kRootWebArea isLineBreakingObject
2379 // ++++2 kGenericContainer isLineBreakingObject
2380 // ++++++3 kStaticText "\n"
2381 // ++++++++4 kInlineTextBox "\n" isLineBreakingObject
2382 // ++++5 kGenericContainer isLineBreakingObject
2383 // ++++++6 kStaticText "some text"
2384 // ++++++++7 kInlineTextBox "some"
2385 // ++++++++8 kInlineTextBox " "
2386 // ++++++++9 kInlineTextBox "text"
2387 // ++++10 kGenericContainer isLineBreakingObject
2388 // ++++++11 kStaticText "\n"
2389 // ++++++++12 kInlineTextBox "\n" isLineBreakingObject
2390
2391 AXNodeData root_data;
2392 root_data.id = 1;
2395 true);
2396
2397 AXNodeData container_data_a;
2398 container_data_a.id = 2;
2399 container_data_a.role = ax::mojom::Role::kGenericContainer;
2400 container_data_a.AddBoolAttribute(
2402
2403 AXNodeData static_text_data_a;
2404 static_text_data_a.id = 3;
2405 static_text_data_a.role = ax::mojom::Role::kStaticText;
2406 static_text_data_a.SetName("\n");
2407
2408 AXNodeData inline_text_data_a;
2409 inline_text_data_a.id = 4;
2410 inline_text_data_a.role = ax::mojom::Role::kInlineTextBox;
2411 inline_text_data_a.SetName("\n");
2412 inline_text_data_a.AddBoolAttribute(
2414
2415 AXNodeData container_data_b;
2416 container_data_b.id = 5;
2417 container_data_b.role = ax::mojom::Role::kGenericContainer;
2418 container_data_b.AddBoolAttribute(
2420
2421 AXNodeData static_text_data_b;
2422 static_text_data_b.id = 6;
2423 static_text_data_b.role = ax::mojom::Role::kStaticText;
2424 static_text_data_b.SetName("some text");
2425
2426 AXNodeData inline_text_data_b_1;
2427 inline_text_data_b_1.id = 7;
2428 inline_text_data_b_1.role = ax::mojom::Role::kInlineTextBox;
2429 inline_text_data_b_1.SetName("some");
2430
2431 AXNodeData inline_text_data_b_2;
2432 inline_text_data_b_2.id = 8;
2433 inline_text_data_b_2.role = ax::mojom::Role::kInlineTextBox;
2434 inline_text_data_b_2.SetName(" ");
2435
2436 AXNodeData inline_text_data_b_3;
2437 inline_text_data_b_3.id = 9;
2438 inline_text_data_b_3.role = ax::mojom::Role::kInlineTextBox;
2439 inline_text_data_b_3.SetName("text");
2440
2441 AXNodeData container_data_c;
2442 container_data_c.id = 10;
2443 container_data_c.role = ax::mojom::Role::kGenericContainer;
2444 container_data_c.AddBoolAttribute(
2446
2447 AXNodeData static_text_data_c;
2448 static_text_data_c.id = 11;
2449 static_text_data_c.role = ax::mojom::Role::kStaticText;
2450 static_text_data_c.SetName("\n");
2451
2452 AXNodeData inline_text_data_c;
2453 inline_text_data_c.id = 12;
2454 inline_text_data_c.role = ax::mojom::Role::kInlineTextBox;
2455 inline_text_data_c.SetName("\n");
2456 inline_text_data_c.AddBoolAttribute(
2458
2459 root_data.child_ids = {container_data_a.id, container_data_b.id,
2460 container_data_c.id};
2461 container_data_a.child_ids = {static_text_data_a.id};
2462 static_text_data_a.child_ids = {inline_text_data_a.id};
2463 container_data_b.child_ids = {static_text_data_b.id};
2464 static_text_data_b.child_ids = {inline_text_data_b_1.id,
2465 inline_text_data_b_2.id,
2466 inline_text_data_b_3.id};
2467 container_data_c.child_ids = {static_text_data_c.id};
2468 static_text_data_c.child_ids = {inline_text_data_c.id};
2469
2470 SetTree(CreateAXTree(
2471 {root_data, container_data_a, container_data_b, container_data_c,
2472 static_text_data_a, static_text_data_b, static_text_data_c,
2473 inline_text_data_a, inline_text_data_b_1, inline_text_data_b_2,
2474 inline_text_data_b_3, inline_text_data_c}));
2475
2476 // Before the first "\n".
2477 TestPositionType text_position1 = AXNodePosition::CreateTextPosition(
2478 GetTreeID(), inline_text_data_a.id, 0 /* text_offset */,
2480 EXPECT_FALSE(text_position1->AtEndOfParagraph());
2481 EXPECT_TRUE(text_position1->AtStartOfParagraph());
2482
2483 // After the first "\n".
2484 //
2485 // Since the position is an "after text" position, it is similar to pressing
2486 // the End key, (or Cmd-Right on Mac), while the caret is on the line break,
2487 // so it should not be "AtStartOfParagraph".
2488 TestPositionType text_position2 = AXNodePosition::CreateTextPosition(
2489 GetTreeID(), inline_text_data_a.id, 1 /* text_offset */,
2491 EXPECT_TRUE(text_position2->AtEndOfParagraph());
2492 EXPECT_FALSE(text_position2->AtStartOfParagraph());
2493
2494 // Before "some".
2495 TestPositionType text_position3 = AXNodePosition::CreateTextPosition(
2496 GetTreeID(), inline_text_data_b_1.id, 0 /* text_offset */,
2498 EXPECT_FALSE(text_position3->AtEndOfParagraph());
2499 EXPECT_TRUE(text_position3->AtStartOfParagraph());
2500
2501 // After "some".
2502 TestPositionType text_position4 = AXNodePosition::CreateTextPosition(
2503 GetTreeID(), inline_text_data_b_1.id, 4 /* text_offset */,
2505 EXPECT_FALSE(text_position4->AtEndOfParagraph());
2506 EXPECT_FALSE(text_position4->AtStartOfParagraph());
2507
2508 // Before " ".
2509 TestPositionType text_position5 = AXNodePosition::CreateTextPosition(
2510 GetTreeID(), inline_text_data_b_2.id, 0 /* text_offset */,
2512 EXPECT_FALSE(text_position5->AtEndOfParagraph());
2513 EXPECT_FALSE(text_position5->AtStartOfParagraph());
2514
2515 // After " ".
2516 TestPositionType text_position6 = AXNodePosition::CreateTextPosition(
2517 GetTreeID(), inline_text_data_b_2.id, 1 /* text_offset */,
2519 EXPECT_FALSE(text_position6->AtEndOfParagraph());
2520 EXPECT_FALSE(text_position6->AtStartOfParagraph());
2521
2522 // Before "text".
2523 TestPositionType text_position7 = AXNodePosition::CreateTextPosition(
2524 GetTreeID(), inline_text_data_b_3.id, 0 /* text_offset */,
2526 EXPECT_FALSE(text_position7->AtEndOfParagraph());
2527 EXPECT_FALSE(text_position7->AtStartOfParagraph());
2528
2529 // After "text".
2530 TestPositionType text_position8 = AXNodePosition::CreateTextPosition(
2531 GetTreeID(), inline_text_data_b_3.id, 4 /* text_offset */,
2533 EXPECT_FALSE(text_position8->AtEndOfParagraph());
2534 EXPECT_FALSE(text_position8->AtStartOfParagraph());
2535
2536 // Before the second "\n".
2537 TestPositionType text_position9 = AXNodePosition::CreateTextPosition(
2538 GetTreeID(), inline_text_data_c.id, 0 /* text_offset */,
2540 EXPECT_FALSE(text_position9->AtEndOfParagraph());
2541 EXPECT_FALSE(text_position9->AtStartOfParagraph());
2542
2543 // After the second "\n".
2544 TestPositionType text_position10 = AXNodePosition::CreateTextPosition(
2545 GetTreeID(), inline_text_data_c.id, 1 /* text_offset */,
2547 EXPECT_TRUE(text_position10->AtEndOfParagraph());
2548 EXPECT_FALSE(text_position10->AtStartOfParagraph());
2549}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kGenericContainer, ax::mojom::kInlineTextBox, ax::mojom::kIsLineBreakingObject, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ TEST_F() [215/325]

ui::TEST_F ( AXPositionTest  ,
Clone   
)

Definition at line 527 of file ax_node_position_unittest.cc.

527 {
528 TestPositionType null_position = AXNodePosition::CreateNullPosition();
529 ASSERT_NE(nullptr, null_position);
530 TestPositionType copy_position = null_position->Clone();
531 ASSERT_NE(nullptr, copy_position);
532 EXPECT_TRUE(copy_position->IsNullPosition());
533
534 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
535 GetTreeID(), root_.id, 1 /* child_index */);
536 ASSERT_NE(nullptr, tree_position);
537 copy_position = tree_position->Clone();
538 ASSERT_NE(nullptr, copy_position);
539 EXPECT_TRUE(copy_position->IsTreePosition());
540 EXPECT_EQ(root_.id, copy_position->anchor_id());
541 EXPECT_EQ(1, copy_position->child_index());
542 EXPECT_EQ(AXNodePosition::INVALID_OFFSET, copy_position->text_offset());
543
544 tree_position = AXNodePosition::CreateTreePosition(
545 GetTreeID(), root_.id, AXNodePosition::BEFORE_TEXT);
546 ASSERT_NE(nullptr, tree_position);
547 copy_position = tree_position->Clone();
548 ASSERT_NE(nullptr, copy_position);
549 EXPECT_TRUE(copy_position->IsTreePosition());
550 EXPECT_EQ(root_.id, copy_position->anchor_id());
551 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, copy_position->child_index());
552 EXPECT_EQ(AXNodePosition::INVALID_OFFSET, copy_position->text_offset());
553
554 TestPositionType text_position = AXNodePosition::CreateTextPosition(
555 GetTreeID(), text_field_.id, 0 /* text_offset */,
557 ASSERT_NE(nullptr, text_position);
558 ASSERT_TRUE(text_position->IsTextPosition());
559 copy_position = text_position->Clone();
560 ASSERT_NE(nullptr, copy_position);
561 EXPECT_TRUE(copy_position->IsTextPosition());
562 EXPECT_EQ(text_field_.id, copy_position->anchor_id());
563 EXPECT_EQ(0, copy_position->text_offset());
564 EXPECT_EQ(ax::mojom::TextAffinity::kUpstream, copy_position->affinity());
565
566 text_position = AXNodePosition::CreateTextPosition(
567 GetTreeID(), text_field_.id, 0 /* text_offset */,
569 ASSERT_NE(nullptr, text_position);
570 ASSERT_TRUE(text_position->IsTextPosition());
571 copy_position = text_position->Clone();
572 ASSERT_NE(nullptr, copy_position);
573 EXPECT_TRUE(copy_position->IsTextPosition());
574 EXPECT_EQ(text_field_.id, copy_position->anchor_id());
575 EXPECT_EQ(0, copy_position->text_offset());
576 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, copy_position->affinity());
577 EXPECT_EQ(AXNodePosition::INVALID_INDEX, copy_position->child_index());
578}

References ui::AXPosition< AXNodePosition, AXNode >::BEFORE_TEXT, ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), ui::AXPosition< AXNodePosition, AXNode >::INVALID_INDEX, ui::AXPosition< AXNodePosition, AXNode >::INVALID_OFFSET, ax::mojom::kDownstream, and ax::mojom::kUpstream.

◆ TEST_F() [216/325]

ui::TEST_F ( AXPositionTest  ,
CreateChildPositionAtWithNullPosition   
)

Definition at line 5173 of file ax_node_position_unittest.cc.

5173 {
5174 TestPositionType null_position = AXNodePosition::CreateNullPosition();
5175 ASSERT_NE(nullptr, null_position);
5176 TestPositionType test_position = null_position->CreateChildPositionAt(0);
5177 EXPECT_NE(nullptr, test_position);
5178 EXPECT_TRUE(test_position->IsNullPosition());
5179}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition().

◆ TEST_F() [217/325]

ui::TEST_F ( AXPositionTest  ,
CreateChildPositionAtWithTextPosition   
)

Definition at line 5201 of file ax_node_position_unittest.cc.

5201 {
5202 TestPositionType text_position = AXNodePosition::CreateTextPosition(
5203 GetTreeID(), static_text1_.id, 5 /* text_offset */,
5205 ASSERT_NE(nullptr, text_position);
5206 ASSERT_TRUE(text_position->IsTextPosition());
5207 TestPositionType test_position = text_position->CreateChildPositionAt(0);
5208 EXPECT_NE(nullptr, test_position);
5209 EXPECT_TRUE(test_position->IsTextPosition());
5210 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
5211 EXPECT_EQ(0, test_position->text_offset());
5212
5213 text_position = AXNodePosition::CreateTextPosition(
5214 GetTreeID(), static_text2_.id, 4 /* text_offset */,
5216 ASSERT_NE(nullptr, text_position);
5217 ASSERT_TRUE(text_position->IsTextPosition());
5218 test_position = text_position->CreateChildPositionAt(1);
5219 EXPECT_NE(nullptr, test_position);
5220 EXPECT_TRUE(test_position->IsNullPosition());
5221}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kDownstream.

◆ TEST_F() [218/325]

ui::TEST_F ( AXPositionTest  ,
CreateChildPositionAtWithTreePosition   
)

Definition at line 5181 of file ax_node_position_unittest.cc.

5181 {
5182 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
5183 GetTreeID(), root_.id, 2 /* child_index */);
5184 ASSERT_NE(nullptr, tree_position);
5185 TestPositionType test_position = tree_position->CreateChildPositionAt(1);
5186 EXPECT_NE(nullptr, test_position);
5187 EXPECT_TRUE(test_position->IsTreePosition());
5188 EXPECT_EQ(check_box_.id, test_position->anchor_id());
5189 // Since the anchor is a leaf node, |child_index| should signify that this is
5190 // a "before text" position.
5191 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
5192
5193 tree_position = AXNodePosition::CreateTreePosition(GetTreeID(), button_.id,
5194 0 /* child_index */);
5195 ASSERT_NE(nullptr, tree_position);
5196 test_position = tree_position->CreateChildPositionAt(0);
5197 EXPECT_NE(nullptr, test_position);
5198 EXPECT_TRUE(test_position->IsNullPosition());
5199}

References ui::AXPosition< AXNodePosition, AXNode >::BEFORE_TEXT, and ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition().

◆ TEST_F() [219/325]

ui::TEST_F ( AXPositionTest  ,
CreateLinePositionsMultipleAnchorsInSingleLine   
)

Definition at line 7089 of file ax_node_position_unittest.cc.

7089 {
7090 // This test updates the tree structure to test a specific edge case -
7091 // Create next and previous line start/end positions on a single line composed
7092 // by multiple anchors; only two line boundaries should be resolved: either
7093 // the start of the "before" text or at the end of "after".
7094 // ++1 kRootWebArea
7095 // ++++2 kStaticText
7096 // ++++++3 kInlineTextBox "before" kNextOnLineId=6
7097 // ++++4 kGenericContainer
7098 // ++++++5 kStaticText
7099 // ++++++++6 kInlineTextBox "inside" kPreviousOnLineId=3 kNextOnLineId=8
7100 // ++++7 kStaticText
7101 // ++++++8 kInlineTextBox "after" kPreviousOnLineId=6
7102 AXNodeData root;
7103 AXNodeData inline_box1;
7104 AXNodeData inline_box2;
7105 AXNodeData inline_box3;
7106 AXNodeData inline_block;
7107 AXNodeData static_text1;
7108 AXNodeData static_text2;
7109 AXNodeData static_text3;
7110
7111 root.id = 1;
7112 static_text1.id = 2;
7113 inline_box1.id = 3;
7114 inline_block.id = 4;
7115 static_text2.id = 5;
7116 inline_box2.id = 6;
7117 static_text3.id = 7;
7118 inline_box3.id = 8;
7119
7121 root.child_ids = {static_text1.id, inline_block.id, static_text3.id};
7122
7123 static_text1.role = ax::mojom::Role::kStaticText;
7124 static_text1.SetName("before");
7125 static_text1.child_ids = {inline_box1.id};
7126
7128 inline_box1.SetName("before");
7130 inline_box2.id);
7131
7133 inline_block.child_ids = {static_text2.id};
7134
7135 static_text2.role = ax::mojom::Role::kStaticText;
7136 static_text2.SetName("inside");
7137 static_text2.child_ids = {inline_box2.id};
7138
7140 inline_box2.SetName("inside");
7142 inline_box1.id);
7144 inline_box3.id);
7145
7146 static_text3.role = ax::mojom::Role::kStaticText;
7147 static_text3.SetName("after");
7148 static_text3.child_ids = {inline_box3.id};
7149
7151 inline_box3.SetName("after");
7153 inline_box2.id);
7154
7155 SetTree(CreateAXTree({root, static_text1, inline_box1, inline_block,
7156 static_text2, inline_box2, static_text3, inline_box3}));
7157
7158 TestPositionType text_position = AXNodePosition::CreateTextPosition(
7159 GetTreeID(), inline_block.id, 3 /* text_offset */,
7161 ASSERT_NE(nullptr, text_position);
7162 ASSERT_TRUE(text_position->IsTextPosition());
7163
7164 TestPositionType next_line_start_position =
7165 text_position->CreateNextLineStartPosition(
7166 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7167 ASSERT_NE(nullptr, next_line_start_position);
7168 EXPECT_TRUE(next_line_start_position->IsTextPosition());
7169 EXPECT_EQ(inline_box3.id, next_line_start_position->anchor_id());
7170 EXPECT_EQ(5, next_line_start_position->text_offset());
7171
7172 TestPositionType previous_line_start_position =
7173 text_position->CreatePreviousLineStartPosition(
7174 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7175 ASSERT_NE(nullptr, previous_line_start_position);
7176 EXPECT_TRUE(previous_line_start_position->IsTextPosition());
7177 EXPECT_EQ(inline_box1.id, previous_line_start_position->anchor_id());
7178 EXPECT_EQ(0, previous_line_start_position->text_offset());
7179
7180 TestPositionType next_line_end_position =
7181 text_position->CreateNextLineEndPosition(
7182 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7183 ASSERT_NE(nullptr, next_line_end_position);
7184 EXPECT_TRUE(next_line_end_position->IsTextPosition());
7185 EXPECT_EQ(inline_box3.id, next_line_end_position->anchor_id());
7186 EXPECT_EQ(5, next_line_end_position->text_offset());
7187
7188 TestPositionType previous_line_end_position =
7189 text_position->CreatePreviousLineEndPosition(
7190 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7191 ASSERT_NE(nullptr, previous_line_end_position);
7192 EXPECT_TRUE(previous_line_end_position->IsTextPosition());
7193 EXPECT_EQ(inline_box1.id, previous_line_end_position->anchor_id());
7194 EXPECT_EQ(0, previous_line_end_position->text_offset());
7195}

References ui::AXNodeData::AddIntAttribute(), ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kGenericContainer, ax::mojom::kInlineTextBox, ax::mojom::kNextOnLineId, ax::mojom::kPreviousOnLineId, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXNodeData::role, ui::AXNodeData::SetName(), and StopAtLastAnchorBoundary.

◆ TEST_F() [220/325]

ui::TEST_F ( AXPositionTest  ,
CreateNextAnchorPosition   
)

Definition at line 7046 of file ax_node_position_unittest.cc.

7046 {
7047 // This test updates the tree structure to test a specific edge case -
7048 // CreateNextAnchorPosition on an empty text field.
7049 AXNodeData root_data;
7050 root_data.id = 1;
7052
7053 AXNodeData text_data;
7054 text_data.id = 2;
7056 text_data.SetName("some text");
7057
7058 AXNodeData text_field_data;
7059 text_field_data.id = 3;
7060 text_field_data.role = ax::mojom::Role::kTextField;
7061
7062 AXNodeData empty_text_data;
7063 empty_text_data.id = 4;
7064 empty_text_data.role = ax::mojom::Role::kStaticText;
7065 empty_text_data.SetName("");
7066
7067 AXNodeData more_text_data;
7068 more_text_data.id = 5;
7069 more_text_data.role = ax::mojom::Role::kStaticText;
7070 more_text_data.SetName("more text");
7071
7072 root_data.child_ids = {text_data.id, text_field_data.id, more_text_data.id};
7073 text_field_data.child_ids = {empty_text_data.id};
7074
7075 SetTree(CreateAXTree({root_data, text_data, text_field_data, empty_text_data,
7076 more_text_data}));
7077
7078 // Test that CreateNextAnchorPosition will successfully navigate past the
7079 // empty text field.
7080 TestPositionType text_position1 = AXNodePosition::CreateTextPosition(
7081 GetTreeID(), text_data.id, 8 /* text_offset */,
7083 ASSERT_NE(nullptr, text_position1);
7084 ASSERT_FALSE(text_position1->CreateNextAnchorPosition()
7085 ->CreateNextAnchorPosition()
7086 ->IsNullPosition());
7087}

References ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ax::mojom::kTextField, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ TEST_F() [221/325]

ui::TEST_F ( AXPositionTest  ,
CreateNextAndPreviousCharacterPositionWithNullPosition   
)

Definition at line 5907 of file ax_node_position_unittest.cc.

5907 {
5908 TestPositionType null_position = AXNodePosition::CreateNullPosition();
5909 ASSERT_NE(nullptr, null_position);
5910 TestPositionType test_position = null_position->CreateNextCharacterPosition(
5911 AXBoundaryBehavior::CrossBoundary);
5912 EXPECT_NE(nullptr, test_position);
5913 EXPECT_TRUE(test_position->IsNullPosition());
5914 test_position = null_position->CreatePreviousCharacterPosition(
5915 AXBoundaryBehavior::CrossBoundary);
5916 EXPECT_NE(nullptr, test_position);
5917 EXPECT_TRUE(test_position->IsNullPosition());
5918}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition(), and CrossBoundary.

◆ TEST_F() [222/325]

ui::TEST_F ( AXPositionTest  ,
CreateNextAndPreviousLeafTextPositionWithNullPosition   
)

Definition at line 5291 of file ax_node_position_unittest.cc.

5291 {
5292 TestPositionType null_position = AXNodePosition::CreateNullPosition();
5293 ASSERT_NE(nullptr, null_position);
5294 TestPositionType test_position = null_position->CreateNextLeafTextPosition();
5295 EXPECT_NE(nullptr, test_position);
5296 EXPECT_TRUE(test_position->IsNullPosition());
5297 test_position = null_position->CreatePreviousLeafTextPosition();
5298 EXPECT_NE(nullptr, test_position);
5299 EXPECT_TRUE(test_position->IsNullPosition());
5300}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition().

◆ TEST_F() [223/325]

ui::TEST_F ( AXPositionTest  ,
CreateNextAndPreviousWordEndPositionWithNullPosition   
)

Definition at line 6641 of file ax_node_position_unittest.cc.

6641 {
6642 TestPositionType null_position = AXNodePosition::CreateNullPosition();
6643 ASSERT_NE(nullptr, null_position);
6644 TestPositionType test_position = null_position->CreateNextWordEndPosition(
6645 AXBoundaryBehavior::CrossBoundary);
6646 EXPECT_NE(nullptr, test_position);
6647 EXPECT_TRUE(test_position->IsNullPosition());
6648 test_position = null_position->CreatePreviousWordEndPosition(
6649 AXBoundaryBehavior::CrossBoundary);
6650 EXPECT_NE(nullptr, test_position);
6651 EXPECT_TRUE(test_position->IsNullPosition());
6652}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition(), and CrossBoundary.

◆ TEST_F() [224/325]

ui::TEST_F ( AXPositionTest  ,
CreateNextAndPreviousWordStartPositionWithNullPosition   
)

Definition at line 6628 of file ax_node_position_unittest.cc.

6628 {
6629 TestPositionType null_position = AXNodePosition::CreateNullPosition();
6630 ASSERT_NE(nullptr, null_position);
6631 TestPositionType test_position = null_position->CreateNextWordStartPosition(
6632 AXBoundaryBehavior::CrossBoundary);
6633 EXPECT_NE(nullptr, test_position);
6634 EXPECT_TRUE(test_position->IsNullPosition());
6635 test_position = null_position->CreatePreviousWordStartPosition(
6636 AXBoundaryBehavior::CrossBoundary);
6637 EXPECT_NE(nullptr, test_position);
6638 EXPECT_TRUE(test_position->IsNullPosition());
6639}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition(), and CrossBoundary.

◆ TEST_F() [225/325]

ui::TEST_F ( AXPositionTest  ,
CreateNextCharacterPosition   
)

Definition at line 6076 of file ax_node_position_unittest.cc.

6076 {
6077 TestPositionType text_position = AXNodePosition::CreateTextPosition(
6078 GetTreeID(), inline_box1_.id, 4 /* text_offset */,
6080 ASSERT_NE(nullptr, text_position);
6081 ASSERT_TRUE(text_position->IsTextPosition());
6082
6083 TestPositionType test_position = text_position->CreateNextCharacterPosition(
6084 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6085 EXPECT_NE(nullptr, test_position);
6086 EXPECT_TRUE(test_position->IsTextPosition());
6087 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6088 EXPECT_EQ(4, test_position->text_offset());
6089 test_position = text_position->CreateNextCharacterPosition(
6090 AXBoundaryBehavior::CrossBoundary);
6091 EXPECT_NE(nullptr, test_position);
6092 EXPECT_TRUE(test_position->IsTextPosition());
6093 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6094 EXPECT_EQ(5, test_position->text_offset());
6095 test_position = text_position->CreateNextCharacterPosition(
6096 AXBoundaryBehavior::StopAtAnchorBoundary);
6097 EXPECT_NE(nullptr, test_position);
6098 EXPECT_TRUE(test_position->IsTextPosition());
6099 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6100 EXPECT_EQ(5, test_position->text_offset());
6101 test_position = text_position->CreateNextCharacterPosition(
6102 AXBoundaryBehavior::StopAtLastAnchorBoundary);
6103 EXPECT_NE(nullptr, test_position);
6104 EXPECT_TRUE(test_position->IsTextPosition());
6105 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6106 EXPECT_EQ(5, test_position->text_offset());
6107
6108 text_position = AXNodePosition::CreateTextPosition(
6109 GetTreeID(), inline_box1_.id, 5 /* text_offset */,
6111 ASSERT_NE(nullptr, text_position);
6112 ASSERT_TRUE(text_position->IsTextPosition());
6113
6114 test_position = text_position->CreateNextCharacterPosition(
6115 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6116 EXPECT_NE(nullptr, test_position);
6117 EXPECT_TRUE(test_position->IsTextPosition());
6118 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6119 EXPECT_EQ(5, test_position->text_offset());
6120 test_position = text_position->CreateNextCharacterPosition(
6121 AXBoundaryBehavior::CrossBoundary);
6122 EXPECT_NE(nullptr, test_position);
6123 EXPECT_TRUE(test_position->IsTextPosition());
6124 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6125 EXPECT_EQ(6, test_position->text_offset());
6126 test_position = text_position->CreateNextCharacterPosition(
6127 AXBoundaryBehavior::StopAtAnchorBoundary);
6128 EXPECT_NE(nullptr, test_position);
6129 EXPECT_TRUE(test_position->IsTextPosition());
6130 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6131 EXPECT_EQ(6, test_position->text_offset());
6132 test_position = text_position->CreateNextCharacterPosition(
6133 AXBoundaryBehavior::StopAtLastAnchorBoundary);
6134 EXPECT_NE(nullptr, test_position);
6135 EXPECT_TRUE(test_position->IsTextPosition());
6136 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6137 EXPECT_EQ(6, test_position->text_offset());
6138
6139 text_position = AXNodePosition::CreateTextPosition(
6140 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
6142 ASSERT_NE(nullptr, text_position);
6143 ASSERT_TRUE(text_position->IsTextPosition());
6144
6145 test_position = text_position->CreateNextCharacterPosition(
6146 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6147 EXPECT_NE(nullptr, test_position);
6148 EXPECT_TRUE(test_position->IsTextPosition());
6149 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6150 EXPECT_EQ(6, test_position->text_offset());
6151 test_position = text_position->CreateNextCharacterPosition(
6152 AXBoundaryBehavior::CrossBoundary);
6153 EXPECT_NE(nullptr, test_position);
6154 EXPECT_TRUE(test_position->IsTextPosition());
6155 EXPECT_EQ(line_break_.id, test_position->anchor_id());
6156 EXPECT_EQ(1, 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_box1_.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(line_break_.id, test_position->anchor_id());
6168 EXPECT_EQ(1, test_position->text_offset());
6169
6170 text_position = AXNodePosition::CreateTextPosition(
6171 GetTreeID(), inline_box2_.id, 6 /* 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->IsNullPosition());
6180 test_position = text_position->CreateNextCharacterPosition(
6181 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6182 EXPECT_NE(nullptr, test_position);
6183 EXPECT_TRUE(test_position->IsTextPosition());
6184 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6185 EXPECT_EQ(6, test_position->text_offset());
6186 test_position = text_position->CreateNextCharacterPosition(
6187 AXBoundaryBehavior::StopAtAnchorBoundary);
6188 EXPECT_NE(nullptr, test_position);
6189 EXPECT_TRUE(test_position->IsTextPosition());
6190 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6191 EXPECT_EQ(6, test_position->text_offset());
6192 test_position = text_position->CreateNextCharacterPosition(
6193 AXBoundaryBehavior::StopAtLastAnchorBoundary);
6194 EXPECT_NE(nullptr, test_position);
6195 EXPECT_TRUE(test_position->IsTextPosition());
6196 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6197 EXPECT_EQ(6, test_position->text_offset());
6198
6199 text_position = AXNodePosition::CreateTextPosition(
6200 GetTreeID(), check_box_.id, 0 /* text_offset */,
6202 ASSERT_NE(nullptr, text_position);
6203 ASSERT_TRUE(text_position->IsTextPosition());
6204
6205 test_position = text_position->CreateNextCharacterPosition(
6206 AXBoundaryBehavior::CrossBoundary);
6207 EXPECT_NE(nullptr, test_position);
6208 EXPECT_TRUE(test_position->IsTextPosition());
6209 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6210 EXPECT_EQ(1, test_position->text_offset());
6211 test_position = text_position->CreateNextCharacterPosition(
6212 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6213 EXPECT_NE(nullptr, test_position);
6214 EXPECT_TRUE(test_position->IsTextPosition());
6215 EXPECT_EQ(check_box_.id, test_position->anchor_id());
6216 EXPECT_EQ(0, test_position->text_offset());
6217 test_position = text_position->CreateNextCharacterPosition(
6218 AXBoundaryBehavior::StopAtAnchorBoundary);
6219 EXPECT_NE(nullptr, test_position);
6220 EXPECT_TRUE(test_position->IsTextPosition());
6221 EXPECT_EQ(check_box_.id, test_position->anchor_id());
6222 EXPECT_EQ(0, test_position->text_offset());
6223 test_position = text_position->CreateNextCharacterPosition(
6224 AXBoundaryBehavior::StopAtLastAnchorBoundary);
6225 EXPECT_NE(nullptr, test_position);
6226 EXPECT_TRUE(test_position->IsTextPosition());
6227 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
6228 EXPECT_EQ(1, test_position->text_offset());
6229
6230 text_position = AXNodePosition::CreateTextPosition(
6231 GetTreeID(), text_field_.id, 0 /* text_offset */,
6233 ASSERT_NE(nullptr, text_position);
6234 ASSERT_TRUE(text_position->IsTextPosition());
6235
6236 test_position = text_position->CreateNextCharacterPosition(
6237 AXBoundaryBehavior::CrossBoundary);
6238 EXPECT_NE(nullptr, test_position);
6239 EXPECT_TRUE(test_position->IsTextPosition());
6240 EXPECT_EQ(text_field_.id, test_position->anchor_id());
6241 EXPECT_EQ(1, test_position->text_offset());
6242 // Affinity should have been reset to downstream.
6243 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
6244
6245 text_position = AXNodePosition::CreateTextPosition(
6246 GetTreeID(), text_field_.id, 12 /* text_offset */,
6248 ASSERT_NE(nullptr, text_position);
6249 ASSERT_TRUE(text_position->IsTextPosition());
6250
6251 test_position = text_position->CreateNextCharacterPosition(
6252 AXBoundaryBehavior::CrossBoundary);
6253 EXPECT_NE(nullptr, test_position);
6254 EXPECT_TRUE(test_position->IsTextPosition());
6255 EXPECT_EQ(text_field_.id, test_position->anchor_id());
6256 EXPECT_EQ(13, test_position->text_offset());
6257 // Affinity should have been reset to downstream.
6258 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
6259}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), CrossBoundary, ax::mojom::kDownstream, ax::mojom::kUpstream, StopAtAnchorBoundary, StopAtLastAnchorBoundary, and StopIfAlreadyAtBoundary.

◆ TEST_F() [226/325]

ui::TEST_F ( AXPositionTest  ,
CreateNextCharacterPositionAtGraphemeBoundary   
)

Definition at line 6430 of file ax_node_position_unittest.cc.

6430 {
6431#if true
6432 GTEST_SKIP()
6433 << "Skipping, current accessibility library cannot handle grapheme";
6434#else
6435 std::vector<int> text_offsets;
6436 SetTree(CreateMultilingualDocument(&text_offsets));
6437
6438 TestPositionType test_position = AXNodePosition::CreateTextPosition(
6439 GetTreeID(), GetTree()->root()->id(), 0 /* text_offset */,
6441 ASSERT_NE(nullptr, test_position);
6442 ASSERT_TRUE(test_position->IsTextPosition());
6443
6444 for (auto iter = (text_offsets.begin() + 1); iter != text_offsets.end();
6445 ++iter) {
6446 const int text_offset = *iter;
6447 test_position = test_position->CreateNextCharacterPosition(
6448 AXBoundaryBehavior::CrossBoundary);
6449 ASSERT_NE(nullptr, test_position);
6450 EXPECT_TRUE(test_position->IsTextPosition());
6451
6452 testing::Message message;
6453 message << "Expecting character boundary at " << text_offset << " in\n"
6454 << *test_position;
6455 SCOPED_TRACE(message);
6456
6457 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
6458 EXPECT_EQ(text_offset, test_position->text_offset());
6459 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
6460 }
6461
6462 test_position = AXNodePosition::CreateTextPosition(
6463 GetTreeID(), GetTree()->root()->id(), 3 /* text_offset */,
6465 test_position = test_position->CreateNextCharacterPosition(
6466 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6467 ASSERT_NE(nullptr, test_position);
6468 EXPECT_TRUE(test_position->IsTextPosition());
6469 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
6470 EXPECT_EQ(3, test_position->text_offset());
6471 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
6472
6473 test_position = AXNodePosition::CreateTextPosition(
6474 GetTreeID(), GetTree()->root()->id(), 4 /* text_offset */,
6476 test_position = test_position->CreateNextCharacterPosition(
6477 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6478 ASSERT_NE(nullptr, test_position);
6479 EXPECT_TRUE(test_position->IsTextPosition());
6480 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
6481 EXPECT_EQ(5, test_position->text_offset());
6482 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
6483
6484 test_position = AXNodePosition::CreateTextPosition(
6485 GetTreeID(), GetTree()->root()->id(), 9 /* text_offset */,
6487 test_position = test_position->CreateNextCharacterPosition(
6488 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6489 ASSERT_NE(nullptr, test_position);
6490 EXPECT_TRUE(test_position->IsTextPosition());
6491 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
6492 EXPECT_EQ(9, test_position->text_offset());
6493 EXPECT_EQ(ax::mojom::TextAffinity::kUpstream, test_position->affinity());
6494
6495 test_position = AXNodePosition::CreateTextPosition(
6496 GetTreeID(), GetTree()->root()->id(), 10 /* text_offset */,
6498 test_position = test_position->CreateNextCharacterPosition(
6499 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6500 ASSERT_NE(nullptr, test_position);
6501 EXPECT_TRUE(test_position->IsTextPosition());
6502 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
6503 EXPECT_EQ(12, test_position->text_offset());
6504 // Affinity should have been reset to downstream because there was a move.
6505 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
6506#endif // true
6507}
G_BEGIN_DECLS GBytes * message

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), CrossBoundary, ax::mojom::kDownstream, ax::mojom::kUpstream, message, and StopIfAlreadyAtBoundary.

◆ TEST_F() [227/325]

ui::TEST_F ( AXPositionTest  ,
CreateNextLeafTextPosition   
)

Definition at line 5302 of file ax_node_position_unittest.cc.

5302 {
5303 TestPositionType check_box_position = AXNodePosition::CreateTreePosition(
5304 GetTreeID(), root_.id, 1 /* child_index */);
5305 ASSERT_NE(nullptr, check_box_position);
5306 TestPositionType test_position =
5307 check_box_position->CreateNextLeafTextPosition();
5308 EXPECT_NE(nullptr, test_position);
5309 EXPECT_TRUE(test_position->IsTextPosition());
5310 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5311 EXPECT_EQ(check_box_.id, test_position->anchor_id());
5312 EXPECT_EQ(0, test_position->text_offset());
5313
5314 // The text offset on the root points to the button since it is the first
5315 // available leaf text position, even though it has no text content.
5316 TestPositionType root_position = AXNodePosition::CreateTextPosition(
5317 GetTreeID(), root_.id, 0 /* text_offset */,
5319 ASSERT_NE(nullptr, root_position);
5320 ASSERT_TRUE(root_position->IsTextPosition());
5321 test_position = root_position->CreateNextLeafTextPosition();
5322 EXPECT_NE(nullptr, test_position);
5323 EXPECT_TRUE(test_position->IsTextPosition());
5324 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5325 EXPECT_EQ(button_.id, test_position->anchor_id());
5326 EXPECT_EQ(0, test_position->text_offset());
5327
5328 TestPositionType button_position = AXNodePosition::CreateTextPosition(
5329 GetTreeID(), button_.id, 0 /* text_offset */,
5331 ASSERT_NE(nullptr, button_position);
5332 ASSERT_TRUE(button_position->IsTextPosition());
5333 test_position = button_position->CreateNextLeafTextPosition();
5334 EXPECT_NE(nullptr, test_position);
5335 EXPECT_TRUE(test_position->IsTextPosition());
5336 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5337 EXPECT_EQ(check_box_.id, test_position->anchor_id());
5338 EXPECT_EQ(0, test_position->text_offset());
5339
5340 test_position = test_position->CreateNextLeafTextPosition();
5341 EXPECT_NE(nullptr, test_position);
5342 EXPECT_TRUE(test_position->IsTextPosition());
5343 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5344 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
5345 EXPECT_EQ(0, test_position->text_offset());
5346
5347 test_position = test_position->CreateNextLeafTextPosition();
5348 EXPECT_NE(nullptr, test_position);
5349 EXPECT_TRUE(test_position->IsTextPosition());
5350 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5351 EXPECT_EQ(line_break_.id, test_position->anchor_id());
5352 EXPECT_EQ(0, test_position->text_offset());
5353
5354 test_position = test_position->CreateNextLeafTextPosition();
5355 EXPECT_NE(nullptr, test_position);
5356 EXPECT_TRUE(test_position->IsTextPosition());
5357 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5358 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5359 EXPECT_EQ(0, test_position->text_offset());
5360
5361 test_position = test_position->CreateNextLeafTextPosition();
5362 EXPECT_NE(nullptr, test_position);
5363 EXPECT_TRUE(test_position->IsNullPosition());
5364
5365 TestPositionType text_field_position = AXNodePosition::CreateTreePosition(
5366 GetTreeID(), root_.id, 2 /* child_index */);
5367 ASSERT_NE(nullptr, text_field_position);
5368 test_position = text_field_position->CreateNextLeafTextPosition();
5369 EXPECT_NE(nullptr, test_position);
5370 EXPECT_TRUE(test_position->IsTextPosition());
5371 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5372 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
5373 EXPECT_EQ(0, test_position->text_offset());
5374
5375 // The root text position should resolve to its leaf text position,
5376 // maintaining its text_offset
5377 TestPositionType root_position2 = AXNodePosition::CreateTextPosition(
5378 GetTreeID(), root_.id, 10 /* text_offset */,
5380 ASSERT_NE(nullptr, root_position2);
5381 ASSERT_TRUE(root_position2->IsTextPosition());
5382 test_position = root_position2->CreateNextLeafTextPosition();
5383 EXPECT_NE(nullptr, test_position);
5384 EXPECT_TRUE(test_position->IsTextPosition());
5385 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5386 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5387 EXPECT_EQ(3, test_position->text_offset());
5388}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), and ax::mojom::kDownstream.

◆ TEST_F() [228/325]

ui::TEST_F ( AXPositionTest  ,
CreateNextLeafTreePosition   
)

Definition at line 5479 of file ax_node_position_unittest.cc.

5479 {
5480 TestPositionType root_position = AXNodePosition::CreateTreePosition(
5481 GetTreeID(), root_.id, 0 /* child_index */);
5482 ASSERT_TRUE(root_position->IsTreePosition());
5483
5484 TestPositionType button_position = AXNodePosition::CreateTreePosition(
5485 GetTreeID(), button_.id, AXNodePosition::BEFORE_TEXT);
5486 TestPositionType checkbox_position = AXNodePosition::CreateTreePosition(
5487 GetTreeID(), check_box_.id, AXNodePosition::BEFORE_TEXT);
5488 TestPositionType inline_box1_position = AXNodePosition::CreateTreePosition(
5489 GetTreeID(), inline_box1_.id, AXNodePosition::BEFORE_TEXT);
5490 TestPositionType line_break_position = AXNodePosition::CreateTreePosition(
5491 GetTreeID(), line_break_.id, AXNodePosition::BEFORE_TEXT);
5492 TestPositionType inline_box2_position = AXNodePosition::CreateTreePosition(
5493 GetTreeID(), inline_box2_.id, AXNodePosition::BEFORE_TEXT);
5494
5495 TestPositionType test_position = root_position->CreateNextLeafTreePosition();
5496 EXPECT_TRUE(test_position->IsTreePosition());
5497 EXPECT_EQ(*test_position, *button_position);
5498
5499 test_position = test_position->CreateNextLeafTreePosition();
5500 EXPECT_TRUE(test_position->IsTreePosition());
5501 EXPECT_EQ(*test_position, *checkbox_position);
5502
5503 test_position = test_position->CreateNextLeafTreePosition();
5504 EXPECT_TRUE(test_position->IsTreePosition());
5505 EXPECT_EQ(*test_position, *inline_box1_position);
5506
5507 test_position = test_position->CreateNextLeafTreePosition();
5508 EXPECT_TRUE(test_position->IsTreePosition());
5509 EXPECT_EQ(*test_position, *line_break_position);
5510
5511 test_position = test_position->CreateNextLeafTreePosition();
5512 EXPECT_TRUE(test_position->IsTreePosition());
5513 EXPECT_EQ(*test_position, *inline_box2_position);
5514
5515 test_position = test_position->CreateNextLeafTreePosition();
5516 EXPECT_TRUE(test_position->IsNullPosition());
5517
5518 TestPositionType root_text_position = AXNodePosition::CreateTextPosition(
5519 GetTreeID(), root_.id, 2 /* text_offset */,
5521 EXPECT_TRUE(root_text_position->IsTextPosition());
5522
5523 test_position = root_text_position->CreateNextLeafTreePosition();
5524 EXPECT_TRUE(test_position->IsTreePosition());
5525 EXPECT_EQ(*test_position, *inline_box1_position);
5526
5527 TestPositionType inline_box1_text_position =
5528 AXNodePosition::CreateTextPosition(GetTreeID(), inline_box1_.id,
5529 2 /* text_offset */,
5531 EXPECT_TRUE(inline_box1_text_position->IsTextPosition());
5532
5533 test_position = inline_box1_text_position->CreateNextLeafTreePosition();
5534 EXPECT_TRUE(test_position->IsTreePosition());
5535 EXPECT_EQ(*test_position, *line_break_position);
5536}

References ui::AXPosition< AXNodePosition, AXNode >::BEFORE_TEXT, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), and ax::mojom::kDownstream.

◆ TEST_F() [229/325]

ui::TEST_F ( AXPositionTest  ,
CreateNextWordPositionInList   
)

Definition at line 7197 of file ax_node_position_unittest.cc.

7197 {
7198 // This test updates the tree structure to test a specific edge case -
7199 // next word navigation inside a list with AXListMarkers nodes.
7200 // ++1 kRootWebArea
7201 // ++++2 kList
7202 // ++++++3 kListItem
7203 // ++++++++4 kListMarker
7204 // ++++++++++5 kStaticText
7205 // ++++++++++++6 kInlineTextBox "1. "
7206 // ++++++++7 kStaticText
7207 // ++++++++++8 kInlineTextBox "first item"
7208 // ++++++9 kListItem
7209 // ++++++++10 kListMarker
7210 // +++++++++++11 kStaticText
7211 // ++++++++++++++12 kInlineTextBox "2. "
7212 // ++++++++13 kStaticText
7213 // ++++++++++14 kInlineTextBox "second item"
7214 AXNodeData root;
7215 AXNodeData list;
7216 AXNodeData list_item1;
7217 AXNodeData list_item2;
7218 AXNodeData list_marker1;
7219 AXNodeData list_marker2;
7220 AXNodeData inline_box1;
7221 AXNodeData inline_box2;
7222 AXNodeData inline_box3;
7223 AXNodeData inline_box4;
7224 AXNodeData static_text1;
7225 AXNodeData static_text2;
7226 AXNodeData static_text3;
7227 AXNodeData static_text4;
7228
7229 root.id = 1;
7230 list.id = 2;
7231 list_item1.id = 3;
7232 list_marker1.id = 4;
7233 static_text1.id = 5;
7234 inline_box1.id = 6;
7235 static_text2.id = 7;
7236 inline_box2.id = 8;
7237 list_item2.id = 9;
7238 list_marker2.id = 10;
7239 static_text3.id = 11;
7240 inline_box3.id = 12;
7241 static_text4.id = 13;
7242 inline_box4.id = 14;
7243
7245 root.child_ids = {list.id};
7246
7248 list.child_ids = {list_item1.id, list_item2.id};
7249
7250 list_item1.role = ax::mojom::Role::kListItem;
7251 list_item1.child_ids = {list_marker1.id, static_text2.id};
7253 true);
7254
7255 list_marker1.role = ax::mojom::Role::kListMarker;
7256 list_marker1.child_ids = {static_text1.id};
7257
7258 static_text1.role = ax::mojom::Role::kStaticText;
7259 static_text1.SetName("1. ");
7260 static_text1.child_ids = {inline_box1.id};
7261
7263 inline_box1.SetName("1. ");
7265 std::vector<int32_t>{0});
7267 std::vector<int32_t>{3});
7268
7269 static_text2.role = ax::mojom::Role::kStaticText;
7270 static_text2.SetName("first item");
7271 static_text2.child_ids = {inline_box2.id};
7272
7274 inline_box2.SetName("first item");
7276 std::vector<int32_t>{0, 6});
7278 std::vector<int32_t>{5});
7279
7280 list_item2.role = ax::mojom::Role::kListItem;
7281 list_item2.child_ids = {list_marker2.id, static_text4.id};
7283 true);
7284
7285 list_marker2.role = ax::mojom::Role::kListMarker;
7286 list_marker2.child_ids = {static_text3.id};
7287
7288 static_text3.role = ax::mojom::Role::kStaticText;
7289 static_text3.SetName("2. ");
7290 static_text3.child_ids = {inline_box3.id};
7291
7293 inline_box3.SetName("2. ");
7295 std::vector<int32_t>{0});
7297 std::vector<int32_t>{3});
7298
7299 static_text4.role = ax::mojom::Role::kStaticText;
7300 static_text4.SetName("second item");
7301 static_text4.child_ids = {inline_box4.id};
7302
7304 inline_box4.SetName("second item");
7306 std::vector<int32_t>{0, 7});
7308 std::vector<int32_t>{6});
7309
7310 SetTree(CreateAXTree({root, list, list_item1, list_marker1, static_text1,
7311 inline_box1, static_text2, inline_box2, list_item2,
7312 list_marker2, static_text3, inline_box3, static_text4,
7313 inline_box4}));
7314
7315 TestPositionType text_position = AXNodePosition::CreateTextPosition(
7316 GetTreeID(), inline_box1.id, 0 /* text_offset */,
7318 ASSERT_NE(nullptr, text_position);
7319 ASSERT_TRUE(text_position->IsTextPosition());
7320 ASSERT_EQ(inline_box1.id, text_position->anchor_id());
7321 ASSERT_EQ(0, text_position->text_offset());
7322
7323 // "1. <f>irst item\n2. second item"
7324 text_position = text_position->CreateNextWordStartPosition(
7325 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7326 ASSERT_NE(nullptr, text_position);
7327 ASSERT_TRUE(text_position->IsTextPosition());
7328 ASSERT_EQ(inline_box2.id, text_position->anchor_id());
7329 ASSERT_EQ(0, text_position->text_offset());
7330
7331 // "1. first <i>tem\n2. second item"
7332 text_position = text_position->CreateNextWordStartPosition(
7333 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7334 ASSERT_NE(nullptr, text_position);
7335 ASSERT_TRUE(text_position->IsTextPosition());
7336 ASSERT_EQ(inline_box2.id, text_position->anchor_id());
7337 ASSERT_EQ(6, text_position->text_offset());
7338
7339 // "1. first item\n<2>. second item"
7340 text_position = text_position->CreateNextWordStartPosition(
7341 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7342 ASSERT_NE(nullptr, text_position);
7343 ASSERT_TRUE(text_position->IsTextPosition());
7344 ASSERT_EQ(inline_box3.id, text_position->anchor_id());
7345 ASSERT_EQ(0, text_position->text_offset());
7346
7347 // "1. first item\n2. <s>econd item"
7348 text_position = text_position->CreateNextWordStartPosition(
7349 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7350 ASSERT_NE(nullptr, text_position);
7351 ASSERT_TRUE(text_position->IsTextPosition());
7352 ASSERT_EQ(inline_box4.id, text_position->anchor_id());
7353 ASSERT_EQ(0, text_position->text_offset());
7354
7355 // "1. first item\n2. second <i>tem"
7356 text_position = text_position->CreateNextWordStartPosition(
7357 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7358 ASSERT_NE(nullptr, text_position);
7359 ASSERT_TRUE(text_position->IsTextPosition());
7360 ASSERT_EQ(inline_box4.id, text_position->anchor_id());
7361 ASSERT_EQ(7, text_position->text_offset());
7362}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::AddIntListAttribute(), ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kInlineTextBox, ax::mojom::kIsLineBreakingObject, ax::mojom::kList, ax::mojom::kListItem, ax::mojom::kListMarker, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ax::mojom::kWordEnds, ax::mojom::kWordStarts, ui::AXNodeData::role, ui::AXNodeData::SetName(), and StopAtLastAnchorBoundary.

◆ TEST_F() [230/325]

ui::TEST_F ( AXPositionTest  ,
CreatePagePositionWithNonPaginatedDocument   
)

Definition at line 4978 of file ax_node_position_unittest.cc.

4978 {
4979 TestPositionType text_position = AXNodePosition::CreateTextPosition(
4980 GetTreeID(), static_text1_.id, 0 /* text_offset */,
4982 ASSERT_NE(nullptr, text_position);
4983
4984 // Non-paginated documents should move to the start of the document for
4985 // CreatePreviousPageStartPosition (treating the entire document as a single
4986 // page)
4987 TestPositionType test_position =
4988 text_position->CreatePreviousPageStartPosition(
4989 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4990 EXPECT_NE(nullptr, test_position);
4991 EXPECT_TRUE(test_position->IsTextPosition());
4992 EXPECT_EQ(button_.id, test_position->anchor_id());
4993 EXPECT_EQ(0, test_position->text_offset());
4994
4995 // Since there is no next page, CreateNextPageStartPosition should return a
4996 // null position
4997 test_position = text_position->CreateNextPageStartPosition(
4998 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4999 EXPECT_NE(nullptr, test_position);
5000 EXPECT_TRUE(test_position->IsNullPosition());
5001
5002 // Since there is no previous page, CreatePreviousPageEndPosition should
5003 // return a null position
5004 test_position = text_position->CreatePreviousPageEndPosition(
5005 AXBoundaryBehavior::CrossBoundary);
5006 EXPECT_NE(nullptr, test_position);
5007 EXPECT_TRUE(test_position->IsNullPosition());
5008
5009 // Since there are no distinct pages, CreateNextPageEndPosition should move
5010 // to the end of the document, as if it's one large page.
5011 test_position = text_position->CreateNextPageEndPosition(
5012 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
5013 EXPECT_NE(nullptr, test_position);
5014 EXPECT_TRUE(test_position->IsTextPosition());
5015 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5016 EXPECT_EQ(6, test_position->text_offset());
5017
5018 // CreatePreviousPageStartPosition should move back to the beginning of the
5019 // document
5020 test_position = test_position->CreatePreviousPageStartPosition(
5021 AXBoundaryBehavior::CrossBoundary);
5022 EXPECT_NE(nullptr, test_position);
5023 EXPECT_TRUE(test_position->IsTextPosition());
5024 EXPECT_EQ(button_.id, test_position->anchor_id());
5025 EXPECT_EQ(0, test_position->text_offset());
5026
5027 // Since there's no next page, CreateNextPageStartPosition should return a
5028 // null position
5029 test_position = test_position->CreateNextPageStartPosition(
5030 AXBoundaryBehavior::CrossBoundary);
5031 EXPECT_NE(nullptr, test_position);
5032 EXPECT_TRUE(test_position->IsNullPosition());
5033
5034 // Since there's no previous page, CreatePreviousPageEndPosition should return
5035 // a null position
5036 test_position = text_position->CreatePreviousPageEndPosition(
5037 AXBoundaryBehavior::CrossBoundary);
5038 EXPECT_NE(nullptr, test_position);
5039 EXPECT_TRUE(test_position->IsNullPosition());
5040
5041 // Since there's no previous page, CreatePreviousPageStartPosition should
5042 // return a null position
5043 test_position = text_position->CreatePreviousPageStartPosition(
5044 AXBoundaryBehavior::CrossBoundary);
5045 EXPECT_NE(nullptr, test_position);
5046 EXPECT_TRUE(test_position->IsNullPosition());
5047}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), CrossBoundary, ax::mojom::kDownstream, and StopIfAlreadyAtBoundary.

◆ TEST_F() [231/325]

ui::TEST_F ( AXPositionTest  ,
CreatePagePositionWithNullPosition   
)

Definition at line 4944 of file ax_node_position_unittest.cc.

4944 {
4945 TestPositionType null_position = AXNodePosition::CreateNullPosition();
4946 ASSERT_NE(nullptr, null_position);
4947 TestPositionType test_position =
4948 null_position->CreatePreviousPageStartPosition(
4949 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4950 EXPECT_NE(nullptr, test_position);
4951 EXPECT_TRUE(test_position->IsNullPosition());
4952
4953 test_position = null_position->CreateNextPageStartPosition(
4954 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4955 EXPECT_NE(nullptr, test_position);
4956 EXPECT_TRUE(test_position->IsNullPosition());
4957
4958 test_position = null_position->CreatePreviousPageEndPosition(
4959 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4960 EXPECT_NE(nullptr, test_position);
4961 EXPECT_TRUE(test_position->IsNullPosition());
4962
4963 test_position = null_position->CreatePreviousPageStartPosition(
4964 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4965 EXPECT_NE(nullptr, test_position);
4966 EXPECT_TRUE(test_position->IsNullPosition());
4967}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition(), and StopIfAlreadyAtBoundary.

◆ TEST_F() [232/325]

ui::TEST_F ( AXPositionTest  ,
CreateParentPositionWithNullPosition   
)

Definition at line 5223 of file ax_node_position_unittest.cc.

5223 {
5224 TestPositionType null_position = AXNodePosition::CreateNullPosition();
5225 ASSERT_NE(nullptr, null_position);
5226 TestPositionType test_position = null_position->CreateParentPosition();
5227 EXPECT_NE(nullptr, test_position);
5228 EXPECT_TRUE(test_position->IsNullPosition());
5229}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition().

◆ TEST_F() [233/325]

ui::TEST_F ( AXPositionTest  ,
CreateParentPositionWithTextPosition   
)

Definition at line 5251 of file ax_node_position_unittest.cc.

5251 {
5252 // Create a position that points at the end of the first line, right after the
5253 // check box.
5254 TestPositionType text_position = AXNodePosition::CreateTextPosition(
5255 GetTreeID(), check_box_.id, 0 /* text_offset */,
5257 ASSERT_NE(nullptr, text_position);
5258 ASSERT_TRUE(text_position->IsTextPosition());
5259 TestPositionType test_position = text_position->CreateParentPosition();
5260 EXPECT_NE(nullptr, test_position);
5261 EXPECT_TRUE(test_position->IsTextPosition());
5262 EXPECT_EQ(root_.id, test_position->anchor_id());
5263 EXPECT_EQ(0, test_position->text_offset());
5264 // Since the same text offset in the root could be used to point to the
5265 // beginning of the second line, affinity should have been adjusted to
5266 // upstream.
5267 EXPECT_EQ(ax::mojom::TextAffinity::kUpstream, test_position->affinity());
5268
5269 text_position = AXNodePosition::CreateTextPosition(
5270 GetTreeID(), inline_box2_.id, 5 /* text_offset */,
5272 ASSERT_NE(nullptr, text_position);
5273 ASSERT_TRUE(text_position->IsTextPosition());
5274 test_position = text_position->CreateParentPosition();
5275 EXPECT_NE(nullptr, test_position);
5276 EXPECT_TRUE(test_position->IsTextPosition());
5277 EXPECT_EQ(static_text2_.id, test_position->anchor_id());
5278 EXPECT_EQ(5, test_position->text_offset());
5279 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
5280
5281 test_position = test_position->CreateParentPosition();
5282 EXPECT_NE(nullptr, test_position);
5283 EXPECT_TRUE(test_position->IsTextPosition());
5284 EXPECT_EQ(text_field_.id, test_position->anchor_id());
5285 // |text_offset| should point to the same offset on the second line where the
5286 // static text node position was pointing at.
5287 EXPECT_EQ(12, test_position->text_offset());
5288 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
5289}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ax::mojom::kDownstream, and ax::mojom::kUpstream.

◆ TEST_F() [234/325]

ui::TEST_F ( AXPositionTest  ,
CreateParentPositionWithTreePosition   
)

Definition at line 5231 of file ax_node_position_unittest.cc.

5231 {
5232 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
5233 GetTreeID(), check_box_.id, 0 /* child_index */);
5234 ASSERT_NE(nullptr, tree_position);
5235 TestPositionType test_position = tree_position->CreateParentPosition();
5236 EXPECT_NE(nullptr, test_position);
5237 EXPECT_TRUE(test_position->IsTreePosition());
5238 EXPECT_EQ(root_.id, test_position->anchor_id());
5239 // |child_index| should point to the check box node.
5240 EXPECT_EQ(1, test_position->child_index());
5241 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
5242
5243 tree_position = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
5244 1 /* child_index */);
5245 ASSERT_NE(nullptr, tree_position);
5246 test_position = tree_position->CreateParentPosition();
5247 EXPECT_NE(nullptr, test_position);
5248 EXPECT_TRUE(test_position->IsNullPosition());
5249}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), and ax::mojom::kDownstream.

◆ TEST_F() [235/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtEndOfAnchorWithNullPosition   
)

Definition at line 4016 of file ax_node_position_unittest.cc.

4016 {
4017 TestPositionType null_position = AXNodePosition::CreateNullPosition();
4018 ASSERT_NE(nullptr, null_position);
4019 TestPositionType test_position = null_position->CreatePositionAtEndOfAnchor();
4020 EXPECT_NE(nullptr, test_position);
4021 EXPECT_TRUE(test_position->IsNullPosition());
4022}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition().

◆ TEST_F() [236/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtEndOfAnchorWithTextPosition   
)

Definition at line 4044 of file ax_node_position_unittest.cc.

4044 {
4045 TestPositionType text_position = AXNodePosition::CreateTextPosition(
4046 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
4048 ASSERT_NE(nullptr, text_position);
4049 ASSERT_TRUE(text_position->IsTextPosition());
4050 TestPositionType test_position = text_position->CreatePositionAtEndOfAnchor();
4051 EXPECT_NE(nullptr, test_position);
4052 EXPECT_TRUE(test_position->IsTextPosition());
4053 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
4054 EXPECT_EQ(6, test_position->text_offset());
4055 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
4056
4057 text_position = AXNodePosition::CreateTextPosition(
4058 GetTreeID(), inline_box1_.id, 5 /* text_offset */,
4060 ASSERT_NE(nullptr, text_position);
4061 ASSERT_TRUE(text_position->IsTextPosition());
4062 test_position = text_position->CreatePositionAtEndOfAnchor();
4063 EXPECT_NE(nullptr, test_position);
4064 EXPECT_TRUE(test_position->IsTextPosition());
4065 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
4066 EXPECT_EQ(6, test_position->text_offset());
4067 // Affinity should have been reset to the default value.
4068 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
4069}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ax::mojom::kDownstream, and ax::mojom::kUpstream.

◆ TEST_F() [237/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtEndOfAnchorWithTreePosition   
)

Definition at line 4024 of file ax_node_position_unittest.cc.

4024 {
4025 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
4026 GetTreeID(), root_.id, 3 /* child_index */);
4027 ASSERT_NE(nullptr, tree_position);
4028 TestPositionType test_position = tree_position->CreatePositionAtEndOfAnchor();
4029 EXPECT_NE(nullptr, test_position);
4030 EXPECT_TRUE(test_position->IsTreePosition());
4031 EXPECT_EQ(root_.id, test_position->anchor_id());
4032 EXPECT_EQ(3, test_position->child_index());
4033
4034 tree_position = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
4035 1 /* child_index */);
4036 ASSERT_NE(nullptr, tree_position);
4037 test_position = tree_position->CreatePositionAtEndOfAnchor();
4038 EXPECT_NE(nullptr, test_position);
4039 EXPECT_TRUE(test_position->IsTreePosition());
4040 EXPECT_EQ(root_.id, test_position->anchor_id());
4041 EXPECT_EQ(3, test_position->child_index());
4042}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition().

◆ TEST_F() [238/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtEndOfDocumentWithNullPosition   
)

Definition at line 5094 of file ax_node_position_unittest.cc.

5094 {
5095 TestPositionType null_position = AXNodePosition::CreateNullPosition();
5096 ASSERT_NE(nullptr, null_position);
5097 TestPositionType test_position =
5098 null_position->CreatePositionAtEndOfDocument();
5099 EXPECT_NE(nullptr, test_position);
5100 EXPECT_TRUE(test_position->IsNullPosition());
5101}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition().

◆ TEST_F() [239/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtEndOfDocumentWithTextPosition   
)

Definition at line 5127 of file ax_node_position_unittest.cc.

5127 {
5128 TestPositionType text_position = AXNodePosition::CreateTextPosition(
5129 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
5131 ASSERT_NE(nullptr, text_position);
5132 TestPositionType test_position =
5133 text_position->CreatePositionAtEndOfDocument();
5134 EXPECT_NE(nullptr, test_position);
5135 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5136
5137 text_position = AXNodePosition::CreateTextPosition(
5138 GetTreeID(), inline_box1_.id, 5 /* text_offset */,
5140 ASSERT_NE(nullptr, text_position);
5141 test_position = text_position->CreatePositionAtEndOfDocument();
5142 EXPECT_NE(nullptr, test_position);
5143 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5144 // Affinity should have been reset to the default value.
5145 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
5146}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ax::mojom::kDownstream, and ax::mojom::kUpstream.

◆ TEST_F() [240/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtEndOfDocumentWithTreePosition   
)

Definition at line 5103 of file ax_node_position_unittest.cc.

5103 {
5104 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
5105 GetTreeID(), root_.id, 3 /* child_index */);
5106 ASSERT_NE(nullptr, tree_position);
5107 TestPositionType test_position =
5108 tree_position->CreatePositionAtEndOfDocument();
5109 EXPECT_NE(nullptr, test_position);
5110 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5111
5112 tree_position = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
5113 1 /* child_index */);
5114 ASSERT_NE(nullptr, tree_position);
5115 test_position = tree_position->CreatePositionAtEndOfDocument();
5116 EXPECT_NE(nullptr, test_position);
5117 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5118
5119 tree_position = AXNodePosition::CreateTreePosition(
5120 GetTreeID(), inline_box1_.id, 0 /* child_index */);
5121 ASSERT_NE(nullptr, tree_position);
5122 test_position = tree_position->CreatePositionAtEndOfDocument();
5123 EXPECT_NE(nullptr, test_position);
5124 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5125}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition().

◆ TEST_F() [241/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtFormatBoundaryWithTextPosition   
)

Definition at line 4321 of file ax_node_position_unittest.cc.

4321 {
4322 // This test updates the tree structure to test a specific edge case -
4323 // CreatePositionAtFormatBoundary when text lies at the beginning and end
4324 // of the AX tree.
4325 AXNodeData root_data;
4326 root_data.id = 1;
4328
4329 AXNodeData text_data;
4330 text_data.id = 2;
4332 text_data.SetName("some text");
4333
4334 AXNodeData more_text_data;
4335 more_text_data.id = 3;
4336 more_text_data.role = ax::mojom::Role::kStaticText;
4337 more_text_data.SetName("more text");
4338
4339 root_data.child_ids = {text_data.id, more_text_data.id};
4340
4341 SetTree(CreateAXTree({root_data, text_data, more_text_data}));
4342
4343 // Test CreatePreviousFormatStartPosition at the start of the document.
4344 TestPositionType text_position = AXNodePosition::CreateTextPosition(
4345 GetTreeID(), text_data.id, 8 /* text_offset */,
4347 ASSERT_NE(nullptr, text_position);
4348 TestPositionType test_position =
4349 text_position->CreatePreviousFormatStartPosition(
4350 AXBoundaryBehavior::CrossBoundary);
4351 EXPECT_NE(nullptr, test_position);
4352 EXPECT_TRUE(test_position->IsTextPosition());
4353 EXPECT_EQ(text_data.id, test_position->anchor_id());
4354 EXPECT_EQ(0, test_position->text_offset());
4355
4356 // Test CreateNextFormatEndPosition at the end of the document.
4357 text_position = AXNodePosition::CreateTextPosition(
4358 GetTreeID(), more_text_data.id, 0 /* text_offset */,
4360 ASSERT_NE(nullptr, text_position);
4361 test_position = text_position->CreateNextFormatEndPosition(
4362 AXBoundaryBehavior::CrossBoundary);
4363 EXPECT_NE(nullptr, test_position);
4364 EXPECT_TRUE(test_position->IsTextPosition());
4365 EXPECT_EQ(more_text_data.id, test_position->anchor_id());
4366 EXPECT_EQ(9, test_position->text_offset());
4367}

References ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), CrossBoundary, ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ TEST_F() [242/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtInvalidGraphemeBoundary   
)

Definition at line 3925 of file ax_node_position_unittest.cc.

3925 {
3926 std::vector<int> text_offsets;
3927 SetTree(CreateMultilingualDocument(&text_offsets));
3928
3929 TestPositionType test_position = AXNodePosition::CreateTextPosition(
3930 GetTreeID(), GetTree()->root()->id(), 4 /* text_offset */,
3932 ASSERT_NE(nullptr, test_position);
3933 EXPECT_TRUE(test_position->IsTextPosition());
3934 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
3935 EXPECT_EQ(4, test_position->text_offset());
3936 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3937
3938 test_position = AXNodePosition::CreateTextPosition(
3939 GetTreeID(), GetTree()->root()->id(), 10 /* text_offset */,
3941 ASSERT_NE(nullptr, test_position);
3942 EXPECT_TRUE(test_position->IsTextPosition());
3943 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
3944 EXPECT_EQ(10, test_position->text_offset());
3945 EXPECT_EQ(ax::mojom::TextAffinity::kUpstream, test_position->affinity());
3946}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ax::mojom::kDownstream, and ax::mojom::kUpstream.

◆ TEST_F() [243/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtNextFormatEndWithNullPosition   
)

Definition at line 4193 of file ax_node_position_unittest.cc.

4193 {
4194 TestPositionType null_position = AXNodePosition::CreateNullPosition();
4195 ASSERT_NE(nullptr, null_position);
4196 TestPositionType test_position = null_position->CreateNextFormatEndPosition(
4197 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4198 EXPECT_NE(nullptr, test_position);
4199 EXPECT_TRUE(test_position->IsNullPosition());
4200 test_position = null_position->CreateNextFormatEndPosition(
4201 AXBoundaryBehavior::CrossBoundary);
4202 EXPECT_NE(nullptr, test_position);
4203 EXPECT_TRUE(test_position->IsNullPosition());
4204}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition(), CrossBoundary, and StopIfAlreadyAtBoundary.

◆ TEST_F() [244/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtNextFormatEndWithTextPosition   
)

Definition at line 4263 of file ax_node_position_unittest.cc.

4263 {
4264 TestPositionType text_position = AXNodePosition::CreateTextPosition(
4265 GetTreeID(), button_.id, 0 /* text_offset */,
4267 ASSERT_NE(nullptr, text_position);
4268 ASSERT_TRUE(text_position->IsTextPosition());
4269
4270 TestPositionType test_position = text_position->CreateNextFormatEndPosition(
4271 AXBoundaryBehavior::CrossBoundary);
4272 EXPECT_NE(nullptr, test_position);
4273 EXPECT_TRUE(test_position->IsTextPosition());
4274 EXPECT_EQ(check_box_.id, test_position->anchor_id());
4275 EXPECT_EQ(0, test_position->text_offset());
4276
4277 test_position = test_position->CreateNextFormatEndPosition(
4278 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4279 EXPECT_NE(nullptr, test_position);
4280 EXPECT_TRUE(test_position->IsTextPosition());
4281 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
4282 EXPECT_EQ(6, test_position->text_offset());
4283
4284 test_position = test_position->CreateNextFormatEndPosition(
4285 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4286 EXPECT_NE(nullptr, test_position);
4287 EXPECT_TRUE(test_position->IsTextPosition());
4288 EXPECT_EQ(line_break_.id, test_position->anchor_id());
4289 EXPECT_EQ(1, test_position->text_offset());
4290
4291 test_position = test_position->CreateNextFormatEndPosition(
4292 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4293 EXPECT_NE(nullptr, test_position);
4294 EXPECT_TRUE(test_position->IsTextPosition());
4295 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
4296 EXPECT_EQ(6, test_position->text_offset());
4297
4298 // StopIfAlreadyAtBoundary shouldn't move, since it's already at a boundary.
4299 test_position = test_position->CreateNextFormatEndPosition(
4300 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4301 EXPECT_NE(nullptr, test_position);
4302 EXPECT_TRUE(test_position->IsTextPosition());
4303 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
4304 EXPECT_EQ(6, test_position->text_offset());
4305
4306 // StopAtLastAnchorBoundary should stop at the end of the document while
4307 // CrossBoundary should return a null position when crossing it.
4308 test_position = test_position->CreateNextFormatEndPosition(
4309 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4310 EXPECT_NE(nullptr, test_position);
4311 EXPECT_TRUE(test_position->IsTextPosition());
4312 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
4313 EXPECT_EQ(6, test_position->text_offset());
4314
4315 test_position = test_position->CreateNextFormatEndPosition(
4316 AXBoundaryBehavior::CrossBoundary);
4317 EXPECT_NE(nullptr, test_position);
4318 EXPECT_TRUE(test_position->IsNullPosition());
4319}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), CrossBoundary, ax::mojom::kDownstream, StopAtLastAnchorBoundary, and StopIfAlreadyAtBoundary.

◆ TEST_F() [245/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtNextFormatEndWithTreePosition   
)

Definition at line 4206 of file ax_node_position_unittest.cc.

4206 {
4207 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
4208 GetTreeID(), button_.id, 0 /* child_index */);
4209 ASSERT_NE(nullptr, tree_position);
4210 ASSERT_TRUE(tree_position->IsTreePosition());
4211
4212 TestPositionType test_position = tree_position->CreateNextFormatEndPosition(
4213 AXBoundaryBehavior::CrossBoundary);
4214 EXPECT_NE(nullptr, test_position);
4215 EXPECT_TRUE(test_position->IsTreePosition());
4216 EXPECT_EQ(check_box_.id, test_position->anchor_id());
4217 EXPECT_EQ(0, test_position->child_index());
4218
4219 test_position = test_position->CreateNextFormatEndPosition(
4220 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4221 EXPECT_NE(nullptr, test_position);
4222 EXPECT_TRUE(test_position->IsTreePosition());
4223 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
4224 EXPECT_EQ(0, test_position->child_index());
4225
4226 test_position = test_position->CreateNextFormatEndPosition(
4227 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4228 EXPECT_NE(nullptr, test_position);
4229 EXPECT_TRUE(test_position->IsTreePosition());
4230 EXPECT_EQ(line_break_.id, test_position->anchor_id());
4231 EXPECT_EQ(0, test_position->child_index());
4232
4233 test_position = test_position->CreateNextFormatEndPosition(
4234 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4235 EXPECT_NE(nullptr, test_position);
4236 EXPECT_TRUE(test_position->IsTreePosition());
4237 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
4238 EXPECT_EQ(0, test_position->child_index());
4239
4240 // StopIfAlreadyAtBoundary shouldn't move, since it's already at a boundary.
4241 test_position = test_position->CreateNextFormatEndPosition(
4242 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4243 EXPECT_NE(nullptr, test_position);
4244 EXPECT_TRUE(test_position->IsTreePosition());
4245 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
4246 EXPECT_EQ(0, test_position->child_index());
4247
4248 // StopAtLastAnchorBoundary should stop at the end of the document while
4249 // CrossBoundary should return a null position when crossing it.
4250 test_position = test_position->CreateNextFormatEndPosition(
4251 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4252 EXPECT_NE(nullptr, test_position);
4253 EXPECT_TRUE(test_position->IsTreePosition());
4254 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
4255 EXPECT_EQ(0, test_position->child_index());
4256
4257 test_position = test_position->CreateNextFormatEndPosition(
4258 AXBoundaryBehavior::CrossBoundary);
4259 EXPECT_NE(nullptr, test_position);
4260 EXPECT_TRUE(test_position->IsNullPosition());
4261}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), CrossBoundary, StopAtLastAnchorBoundary, and StopIfAlreadyAtBoundary.

◆ TEST_F() [246/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtPageBoundaryWithTextPosition   
)

Definition at line 4637 of file ax_node_position_unittest.cc.

4637 {
4638 AXNodeData root_data, page_1_data, page_1_text_data, page_2_data,
4639 page_2_text_data, page_3_data, page_3_text_data;
4640 SetTree(CreateMultipageDocument(root_data, page_1_data, page_1_text_data,
4641 page_2_data, page_2_text_data, page_3_data,
4642 page_3_text_data));
4643
4644 // Test CreateNextPageStartPosition at the start of the document.
4645 TestPositionType text_position = AXNodePosition::CreateTextPosition(
4646 GetTreeID(), page_1_text_data.id, 0 /* text_offset */,
4648 ASSERT_NE(nullptr, text_position);
4649 ASSERT_TRUE(text_position->IsTextPosition());
4650
4651 // StopIfAlreadyAtBoundary shouldn't move at all since it's at a boundary.
4652 TestPositionType test_position = text_position->CreateNextPageStartPosition(
4653 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4654 EXPECT_NE(nullptr, test_position);
4655 EXPECT_TRUE(test_position->IsTextPosition());
4656 EXPECT_EQ(page_1_text_data.id, test_position->anchor_id());
4657 EXPECT_EQ(0, test_position->text_offset());
4658
4659 test_position = text_position->CreateNextPageStartPosition(
4660 AXBoundaryBehavior::CrossBoundary);
4661 EXPECT_NE(nullptr, test_position);
4662 EXPECT_TRUE(test_position->IsTextPosition());
4663 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4664 EXPECT_EQ(0, test_position->text_offset());
4665
4666 test_position = text_position->CreateNextPageStartPosition(
4667 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4668 EXPECT_NE(nullptr, test_position);
4669 EXPECT_TRUE(test_position->IsTextPosition());
4670 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4671 EXPECT_EQ(0, test_position->text_offset());
4672
4673 // Test CreateNextPageEndPosition until the end of document is reached.
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_2_text_data.id, test_position->anchor_id());
4679 EXPECT_EQ(19, test_position->text_offset());
4680
4681 test_position = test_position->CreateNextPageEndPosition(
4682 AXBoundaryBehavior::CrossBoundary);
4683 EXPECT_NE(nullptr, test_position);
4684 EXPECT_TRUE(test_position->IsTextPosition());
4685 EXPECT_EQ(page_3_text_data.id, test_position->anchor_id());
4686 EXPECT_EQ(24, test_position->text_offset());
4687
4688 test_position = test_position->CreateNextPageEndPosition(
4689 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4690 EXPECT_NE(nullptr, test_position);
4691 EXPECT_TRUE(test_position->IsTextPosition());
4692 EXPECT_EQ(page_3_text_data.id, test_position->anchor_id());
4693 EXPECT_EQ(24, test_position->text_offset());
4694
4695 // StopAtLastAnchorBoundary shouldn't move past the end of the document.
4696 test_position = test_position->CreateNextPageStartPosition(
4697 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4698 EXPECT_NE(nullptr, test_position);
4699 EXPECT_TRUE(test_position->IsTextPosition());
4700 EXPECT_EQ(page_3_text_data.id, test_position->anchor_id());
4701 EXPECT_EQ(24, test_position->text_offset());
4702
4703 test_position = test_position->CreateNextPageEndPosition(
4704 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4705 EXPECT_NE(nullptr, test_position);
4706 EXPECT_TRUE(test_position->IsTextPosition());
4707 EXPECT_EQ(page_3_text_data.id, test_position->anchor_id());
4708 EXPECT_EQ(24, test_position->text_offset());
4709
4710 // Moving forward past the end should return a null position.
4711 TestPositionType null_position = test_position->CreateNextPageStartPosition(
4712 AXBoundaryBehavior::CrossBoundary);
4713 EXPECT_NE(nullptr, null_position);
4714 EXPECT_TRUE(null_position->IsNullPosition());
4715
4716 null_position = test_position->CreateNextPageEndPosition(
4717 AXBoundaryBehavior::CrossBoundary);
4718 EXPECT_NE(nullptr, null_position);
4719 EXPECT_TRUE(null_position->IsNullPosition());
4720
4721 // Now move backward through the document.
4722 text_position = test_position->CreatePreviousPageEndPosition(
4723 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4724 EXPECT_NE(nullptr, text_position);
4725 EXPECT_TRUE(text_position->IsTextPosition());
4726 EXPECT_EQ(page_3_text_data.id, text_position->anchor_id());
4727 EXPECT_EQ(24, text_position->text_offset());
4728
4729 test_position = text_position->CreatePreviousPageEndPosition(
4730 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4731 EXPECT_NE(nullptr, test_position);
4732 EXPECT_TRUE(test_position->IsTextPosition());
4733 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4734 EXPECT_EQ(19, test_position->text_offset());
4735
4736 test_position = text_position->CreatePreviousPageEndPosition(
4737 AXBoundaryBehavior::CrossBoundary);
4738 EXPECT_NE(nullptr, test_position);
4739 EXPECT_TRUE(test_position->IsTextPosition());
4740 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4741 EXPECT_EQ(19, test_position->text_offset());
4742
4743 test_position = test_position->CreatePreviousPageStartPosition(
4744 AXBoundaryBehavior::CrossBoundary);
4745 EXPECT_NE(nullptr, test_position);
4746 EXPECT_TRUE(test_position->IsTextPosition());
4747 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4748 EXPECT_EQ(0, test_position->text_offset());
4749
4750 test_position = test_position->CreatePreviousPageStartPosition(
4751 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4752 EXPECT_NE(nullptr, test_position);
4753 EXPECT_TRUE(test_position->IsTextPosition());
4754 EXPECT_EQ(page_1_text_data.id, test_position->anchor_id());
4755 EXPECT_EQ(0, test_position->text_offset());
4756
4757 test_position = test_position->CreatePreviousPageStartPosition(
4758 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4759 EXPECT_NE(nullptr, test_position);
4760 EXPECT_TRUE(test_position->IsTextPosition());
4761 EXPECT_EQ(page_1_text_data.id, test_position->anchor_id());
4762 EXPECT_EQ(0, test_position->text_offset());
4763
4764 // StopAtLastAnchorBoundary shouldn't move past the start of the document.
4765 test_position = test_position->CreatePreviousPageStartPosition(
4766 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4767 EXPECT_NE(nullptr, test_position);
4768 EXPECT_TRUE(test_position->IsTextPosition());
4769 EXPECT_EQ(page_1_text_data.id, test_position->anchor_id());
4770 EXPECT_EQ(0, test_position->text_offset());
4771
4772 test_position = test_position->CreatePreviousPageEndPosition(
4773 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4774 EXPECT_NE(nullptr, test_position);
4775 EXPECT_TRUE(test_position->IsTextPosition());
4776 EXPECT_EQ(page_1_text_data.id, test_position->anchor_id());
4777 EXPECT_EQ(0, test_position->text_offset());
4778
4779 // Moving before the start should return a null position.
4780 null_position = test_position->CreatePreviousPageStartPosition(
4781 AXBoundaryBehavior::CrossBoundary);
4782 EXPECT_NE(nullptr, null_position);
4783 EXPECT_TRUE(null_position->IsNullPosition());
4784
4785 null_position = test_position->CreatePreviousPageEndPosition(
4786 AXBoundaryBehavior::CrossBoundary);
4787 EXPECT_NE(nullptr, null_position);
4788 EXPECT_TRUE(null_position->IsNullPosition());
4789}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), CrossBoundary, ui::AXNodeData::id, ax::mojom::kDownstream, StopAtLastAnchorBoundary, and StopIfAlreadyAtBoundary.

◆ TEST_F() [247/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtPageBoundaryWithTreePosition   
)

Definition at line 4791 of file ax_node_position_unittest.cc.

4791 {
4792 AXNodeData root_data, page_1_data, page_1_text_data, page_2_data,
4793 page_2_text_data, page_3_data, page_3_text_data;
4794 SetTree(CreateMultipageDocument(root_data, page_1_data, page_1_text_data,
4795 page_2_data, page_2_text_data, page_3_data,
4796 page_3_text_data));
4797
4798 // Test CreateNextPageStartPosition at the start of the document.
4799 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
4800 GetTreeID(), page_1_data.id, 0 /* child_index */);
4801 ASSERT_NE(nullptr, tree_position);
4802 ASSERT_TRUE(tree_position->IsTreePosition());
4803
4804 // StopIfAlreadyAtBoundary shouldn't move at all since it's at a boundary.
4805 TestPositionType test_position = tree_position->CreateNextPageStartPosition(
4806 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4807 EXPECT_NE(nullptr, test_position);
4808 EXPECT_TRUE(test_position->IsTreePosition());
4809 EXPECT_EQ(page_1_data.id, test_position->anchor_id());
4810 EXPECT_EQ(0, test_position->child_index());
4811
4812 test_position = tree_position->CreateNextPageStartPosition(
4813 AXBoundaryBehavior::CrossBoundary);
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(AXNodePosition::BEFORE_TEXT, test_position->child_index());
4818
4819 test_position = tree_position->CreateNextPageStartPosition(
4820 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4821 EXPECT_NE(nullptr, test_position);
4822 EXPECT_TRUE(test_position->IsTreePosition());
4823 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4824 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
4825
4826 // Test CreateNextPageEndPosition until the end of document is reached.
4827 test_position = tree_position->CreateNextPageEndPosition(
4828 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4829 EXPECT_NE(nullptr, test_position);
4830 EXPECT_TRUE(test_position->IsTreePosition());
4831 EXPECT_EQ(page_1_data.id, test_position->anchor_id());
4832 EXPECT_EQ(1, test_position->child_index());
4833
4834 test_position = test_position->CreateNextPageEndPosition(
4835 AXBoundaryBehavior::CrossBoundary);
4836 EXPECT_NE(nullptr, test_position);
4837 EXPECT_TRUE(test_position->IsTreePosition());
4838 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4839 EXPECT_EQ(0, test_position->child_index());
4840
4841 test_position = test_position->CreateNextPageEndPosition(
4842 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4843 EXPECT_NE(nullptr, test_position);
4844 EXPECT_TRUE(test_position->IsTreePosition());
4845 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4846 EXPECT_EQ(0, test_position->child_index());
4847
4848 // StopAtLastAnchorBoundary shouldn't move past the end of the document.
4849 test_position = test_position->CreateNextPageStartPosition(
4850 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4851 EXPECT_NE(nullptr, test_position);
4852 EXPECT_TRUE(test_position->IsTreePosition());
4853 EXPECT_EQ(page_3_text_data.id, test_position->anchor_id());
4854 EXPECT_EQ(0, test_position->child_index());
4855
4856 test_position = test_position->CreateNextPageEndPosition(
4857 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4858 EXPECT_NE(nullptr, test_position);
4859 EXPECT_TRUE(test_position->IsTreePosition());
4860 EXPECT_EQ(page_3_text_data.id, test_position->anchor_id());
4861 EXPECT_EQ(0, test_position->child_index());
4862
4863 // Moving forward past the end should return a null position.
4864 TestPositionType null_position = test_position->CreateNextPageStartPosition(
4865 AXBoundaryBehavior::CrossBoundary);
4866 EXPECT_NE(nullptr, null_position);
4867 EXPECT_TRUE(null_position->IsNullPosition());
4868
4869 null_position = test_position->CreateNextPageEndPosition(
4870 AXBoundaryBehavior::CrossBoundary);
4871 EXPECT_NE(nullptr, null_position);
4872 EXPECT_TRUE(null_position->IsNullPosition());
4873
4874 // Now move backward through the document.
4875 tree_position = test_position->CreatePreviousPageEndPosition(
4876 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4877 EXPECT_NE(nullptr, tree_position);
4878 EXPECT_TRUE(tree_position->IsTreePosition());
4879 EXPECT_EQ(page_3_text_data.id, tree_position->anchor_id());
4880 EXPECT_EQ(0, tree_position->child_index());
4881
4882 test_position = tree_position->CreatePreviousPageEndPosition(
4883 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4884 EXPECT_NE(nullptr, test_position);
4885 EXPECT_TRUE(test_position->IsTreePosition());
4886 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4887 EXPECT_EQ(0, test_position->child_index());
4888
4889 test_position = tree_position->CreatePreviousPageEndPosition(
4890 AXBoundaryBehavior::CrossBoundary);
4891 EXPECT_NE(nullptr, test_position);
4892 EXPECT_TRUE(test_position->IsTreePosition());
4893 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4894 EXPECT_EQ(0, test_position->child_index());
4895
4896 test_position = test_position->CreatePreviousPageStartPosition(
4897 AXBoundaryBehavior::CrossBoundary);
4898 EXPECT_NE(nullptr, test_position);
4899 EXPECT_TRUE(test_position->IsTreePosition());
4900 EXPECT_EQ(page_2_text_data.id, test_position->anchor_id());
4901 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
4902
4903 test_position = test_position->CreatePreviousPageStartPosition(
4904 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4905 EXPECT_NE(nullptr, test_position);
4906 EXPECT_TRUE(test_position->IsTreePosition());
4907 EXPECT_EQ(page_1_text_data.id, test_position->anchor_id());
4908 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
4909
4910 test_position = test_position->CreatePreviousPageStartPosition(
4911 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4912 EXPECT_NE(nullptr, test_position);
4913 EXPECT_TRUE(test_position->IsTreePosition());
4914 EXPECT_EQ(page_1_text_data.id, test_position->anchor_id());
4915 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
4916
4917 // StopAtLastAnchorBoundary shouldn't move past the start of the document.
4918 test_position = test_position->CreatePreviousPageStartPosition(
4919 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4920 EXPECT_NE(nullptr, test_position);
4921 EXPECT_TRUE(test_position->IsTreePosition());
4922 EXPECT_EQ(page_1_text_data.id, test_position->anchor_id());
4923 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
4924
4925 test_position = test_position->CreatePreviousPageEndPosition(
4926 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4927 EXPECT_NE(nullptr, test_position);
4928 EXPECT_TRUE(test_position->IsTreePosition());
4929 EXPECT_EQ(page_1_text_data.id, test_position->anchor_id());
4930 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
4931
4932 // Moving before the start should return a null position.
4933 null_position = test_position->CreatePreviousPageStartPosition(
4934 AXBoundaryBehavior::CrossBoundary);
4935 EXPECT_NE(nullptr, null_position);
4936 EXPECT_TRUE(null_position->IsNullPosition());
4937
4938 null_position = test_position->CreatePreviousPageEndPosition(
4939 AXBoundaryBehavior::CrossBoundary);
4940 EXPECT_NE(nullptr, null_position);
4941 EXPECT_TRUE(null_position->IsNullPosition());
4942}

References ui::AXPosition< AXNodePosition, AXNode >::BEFORE_TEXT, ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), CrossBoundary, ui::AXNodeData::id, StopAtLastAnchorBoundary, and StopIfAlreadyAtBoundary.

◆ TEST_F() [248/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtPreviousFormatStartWithNullPosition   
)

Definition at line 4071 of file ax_node_position_unittest.cc.

4071 {
4072 TestPositionType null_position = AXNodePosition::CreateNullPosition();
4073 ASSERT_NE(nullptr, null_position);
4074 TestPositionType test_position =
4075 null_position->CreatePreviousFormatStartPosition(
4076 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4077 EXPECT_NE(nullptr, test_position);
4078 EXPECT_TRUE(test_position->IsNullPosition());
4079 test_position = null_position->CreatePreviousFormatStartPosition(
4080 AXBoundaryBehavior::CrossBoundary);
4081 EXPECT_NE(nullptr, test_position);
4082 EXPECT_TRUE(test_position->IsNullPosition());
4083 test_position = null_position->CreatePreviousFormatStartPosition(
4084 AXBoundaryBehavior::StopAtAnchorBoundary);
4085 EXPECT_NE(nullptr, test_position);
4086 EXPECT_TRUE(test_position->IsNullPosition());
4087}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition(), CrossBoundary, StopAtAnchorBoundary, and StopIfAlreadyAtBoundary.

◆ TEST_F() [249/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtPreviousFormatStartWithTextPosition   
)

Definition at line 4140 of file ax_node_position_unittest.cc.

4140 {
4141 TestPositionType text_position = AXNodePosition::CreateTextPosition(
4142 GetTreeID(), inline_box1_.id, 2 /* text_offset */,
4144 ASSERT_NE(nullptr, text_position);
4145 ASSERT_TRUE(text_position->IsTextPosition());
4146
4147 TestPositionType test_position =
4148 text_position->CreatePreviousFormatStartPosition(
4149 AXBoundaryBehavior::CrossBoundary);
4150 EXPECT_NE(nullptr, test_position);
4151 EXPECT_TRUE(test_position->IsTextPosition());
4152 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
4153 EXPECT_EQ(0, test_position->text_offset());
4154 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
4155
4156 test_position = test_position->CreatePreviousFormatStartPosition(
4157 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4158 EXPECT_NE(nullptr, test_position);
4159 EXPECT_TRUE(test_position->IsTextPosition());
4160 EXPECT_EQ(check_box_.id, test_position->anchor_id());
4161 EXPECT_EQ(0, test_position->text_offset());
4162
4163 test_position = test_position->CreatePreviousFormatStartPosition(
4164 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4165 EXPECT_NE(nullptr, test_position);
4166 EXPECT_TRUE(test_position->IsTextPosition());
4167 EXPECT_EQ(button_.id, test_position->anchor_id());
4168 EXPECT_EQ(0, test_position->text_offset());
4169
4170 // StopIfAlreadyAtBoundary shouldn't move, since it's already at a boundary.
4171 test_position = test_position->CreatePreviousFormatStartPosition(
4172 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4173 EXPECT_NE(nullptr, test_position);
4174 EXPECT_TRUE(test_position->IsTextPosition());
4175 EXPECT_EQ(button_.id, test_position->anchor_id());
4176 EXPECT_EQ(0, test_position->text_offset());
4177
4178 // StopAtLastAnchorBoundary should stop at the start of the document while
4179 // CrossBoundary should return a null position when crossing it.
4180 test_position = test_position->CreatePreviousFormatStartPosition(
4181 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4182 EXPECT_NE(nullptr, test_position);
4183 EXPECT_TRUE(test_position->IsTextPosition());
4184 EXPECT_EQ(button_.id, test_position->anchor_id());
4185 EXPECT_EQ(0, test_position->text_offset());
4186
4187 test_position = test_position->CreatePreviousFormatStartPosition(
4188 AXBoundaryBehavior::CrossBoundary);
4189 EXPECT_NE(nullptr, test_position);
4190 EXPECT_TRUE(test_position->IsNullPosition());
4191}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), CrossBoundary, ax::mojom::kDownstream, StopAtLastAnchorBoundary, and StopIfAlreadyAtBoundary.

◆ TEST_F() [250/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtPreviousFormatStartWithTreePosition   
)

Definition at line 4089 of file ax_node_position_unittest.cc.

4089 {
4090 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
4091 GetTreeID(), static_text1_.id, 1 /* child_index */);
4092 ASSERT_NE(nullptr, tree_position);
4093 ASSERT_TRUE(tree_position->IsTreePosition());
4094
4095 TestPositionType test_position =
4096 tree_position->CreatePreviousFormatStartPosition(
4097 AXBoundaryBehavior::CrossBoundary);
4098 EXPECT_NE(nullptr, test_position);
4099 EXPECT_TRUE(test_position->IsTreePosition());
4100 EXPECT_EQ(static_text1_.id, test_position->anchor_id());
4101 EXPECT_EQ(0, test_position->child_index());
4102
4103 test_position = test_position->CreatePreviousFormatStartPosition(
4104 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4105 EXPECT_NE(nullptr, test_position);
4106 EXPECT_TRUE(test_position->IsTreePosition());
4107 EXPECT_EQ(check_box_.id, test_position->anchor_id());
4108 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
4109
4110 test_position = test_position->CreatePreviousFormatStartPosition(
4111 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4112 EXPECT_NE(nullptr, test_position);
4113 EXPECT_TRUE(test_position->IsTreePosition());
4114 EXPECT_EQ(button_.id, test_position->anchor_id());
4115 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
4116
4117 // StopIfAlreadyAtBoundary shouldn't move, since it's already at a boundary.
4118 test_position = test_position->CreatePreviousFormatStartPosition(
4119 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
4120 EXPECT_NE(nullptr, test_position);
4121 EXPECT_TRUE(test_position->IsTreePosition());
4122 EXPECT_EQ(button_.id, test_position->anchor_id());
4123 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
4124
4125 // StopAtLastAnchorBoundary should stop at the start of the document while
4126 // CrossBoundary should return a null position when crossing it.
4127 test_position = test_position->CreatePreviousFormatStartPosition(
4128 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4129 EXPECT_NE(nullptr, test_position);
4130 EXPECT_TRUE(test_position->IsTreePosition());
4131 EXPECT_EQ(button_.id, test_position->anchor_id());
4132 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
4133
4134 test_position = test_position->CreatePreviousFormatStartPosition(
4135 AXBoundaryBehavior::CrossBoundary);
4136 EXPECT_NE(nullptr, test_position);
4137 EXPECT_TRUE(test_position->IsNullPosition());
4138}

References ui::AXPosition< AXNodePosition, AXNode >::BEFORE_TEXT, ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), CrossBoundary, StopAtLastAnchorBoundary, and StopIfAlreadyAtBoundary.

◆ TEST_F() [251/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtStartOfAnchorWithNullPosition   
)

Definition at line 3948 of file ax_node_position_unittest.cc.

3948 {
3949 TestPositionType null_position = AXNodePosition::CreateNullPosition();
3950 ASSERT_NE(nullptr, null_position);
3951 TestPositionType test_position =
3952 null_position->CreatePositionAtStartOfAnchor();
3953 EXPECT_NE(nullptr, test_position);
3954 EXPECT_TRUE(test_position->IsNullPosition());
3955}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition().

◆ TEST_F() [252/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtStartOfAnchorWithTextPosition   
)

Definition at line 3988 of file ax_node_position_unittest.cc.

3988 {
3989 TestPositionType text_position = AXNodePosition::CreateTextPosition(
3990 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
3992 ASSERT_NE(nullptr, text_position);
3993 ASSERT_TRUE(text_position->IsTextPosition());
3994 TestPositionType test_position =
3995 text_position->CreatePositionAtStartOfAnchor();
3996 ASSERT_NE(nullptr, test_position);
3997 EXPECT_TRUE(test_position->IsTextPosition());
3998 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3999 EXPECT_EQ(0, test_position->text_offset());
4000 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
4001
4002 text_position = AXNodePosition::CreateTextPosition(
4003 GetTreeID(), inline_box1_.id, 1 /* text_offset */,
4005 ASSERT_NE(nullptr, text_position);
4006 ASSERT_TRUE(text_position->IsTextPosition());
4007 test_position = text_position->CreatePositionAtStartOfAnchor();
4008 EXPECT_NE(nullptr, test_position);
4009 EXPECT_TRUE(test_position->IsTextPosition());
4010 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
4011 EXPECT_EQ(0, test_position->text_offset());
4012 // Affinity should have been reset to the default value.
4013 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
4014}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ax::mojom::kDownstream, and ax::mojom::kUpstream.

◆ TEST_F() [253/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtStartOfAnchorWithTreePosition   
)

Definition at line 3957 of file ax_node_position_unittest.cc.

3957 {
3958 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
3959 GetTreeID(), root_.id, 0 /* child_index */);
3960 ASSERT_NE(nullptr, tree_position);
3961 TestPositionType test_position =
3962 tree_position->CreatePositionAtStartOfAnchor();
3963 EXPECT_NE(nullptr, test_position);
3964 EXPECT_TRUE(test_position->IsTreePosition());
3965 EXPECT_EQ(root_.id, test_position->anchor_id());
3966 EXPECT_EQ(0, test_position->child_index());
3967
3968 tree_position = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
3969 1 /* child_index */);
3970 ASSERT_NE(nullptr, tree_position);
3971 test_position = tree_position->CreatePositionAtStartOfAnchor();
3972 EXPECT_NE(nullptr, test_position);
3973 EXPECT_TRUE(test_position->IsTreePosition());
3974 EXPECT_EQ(root_.id, test_position->anchor_id());
3975 EXPECT_EQ(0, test_position->child_index());
3976
3977 // An "after text" position.
3978 tree_position = AXNodePosition::CreateTreePosition(
3979 GetTreeID(), inline_box1_.id, 0 /* child_index */);
3980 ASSERT_NE(nullptr, tree_position);
3981 test_position = tree_position->CreatePositionAtStartOfAnchor();
3982 EXPECT_NE(nullptr, test_position);
3983 EXPECT_TRUE(test_position->IsTreePosition());
3984 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
3985 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, test_position->child_index());
3986}

References ui::AXPosition< AXNodePosition, AXNode >::BEFORE_TEXT, and ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition().

◆ TEST_F() [254/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtStartOfDocumentWithNullPosition   
)

Definition at line 4969 of file ax_node_position_unittest.cc.

4969 {
4970 TestPositionType null_position = AXNodePosition::CreateNullPosition();
4971 ASSERT_NE(nullptr, null_position);
4972 TestPositionType test_position =
4973 null_position->CreatePositionAtStartOfDocument();
4974 EXPECT_NE(nullptr, test_position);
4975 EXPECT_TRUE(test_position->IsNullPosition());
4976}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition().

◆ TEST_F() [255/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtStartOfDocumentWithTextPosition   
)

Definition at line 5073 of file ax_node_position_unittest.cc.

5073 {
5074 TestPositionType text_position = AXNodePosition::CreateTextPosition(
5075 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
5077 ASSERT_NE(nullptr, text_position);
5078 TestPositionType test_position =
5079 text_position->CreatePositionAtStartOfDocument();
5080 EXPECT_NE(nullptr, test_position);
5081 EXPECT_EQ(root_.id, test_position->anchor_id());
5082
5083 text_position = AXNodePosition::CreateTextPosition(
5084 GetTreeID(), inline_box1_.id, 1 /* text_offset */,
5086 ASSERT_NE(nullptr, text_position);
5087 test_position = text_position->CreatePositionAtStartOfDocument();
5088 EXPECT_NE(nullptr, test_position);
5089 EXPECT_EQ(root_.id, test_position->anchor_id());
5090 // Affinity should have been reset to the default value.
5091 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
5092}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ax::mojom::kDownstream, and ax::mojom::kUpstream.

◆ TEST_F() [256/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtStartOfDocumentWithTreePosition   
)

Definition at line 5049 of file ax_node_position_unittest.cc.

5049 {
5050 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
5051 GetTreeID(), root_.id, 0 /* child_index */);
5052 ASSERT_NE(nullptr, tree_position);
5053 TestPositionType test_position =
5054 tree_position->CreatePositionAtStartOfDocument();
5055 EXPECT_NE(nullptr, test_position);
5056 EXPECT_EQ(root_.id, test_position->anchor_id());
5057
5058 tree_position = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
5059 1 /* child_index */);
5060 ASSERT_NE(nullptr, tree_position);
5061 test_position = tree_position->CreatePositionAtStartOfDocument();
5062 EXPECT_NE(nullptr, test_position);
5063 EXPECT_EQ(root_.id, test_position->anchor_id());
5064
5065 tree_position = AXNodePosition::CreateTreePosition(
5066 GetTreeID(), inline_box1_.id, 0 /* child_index */);
5067 ASSERT_NE(nullptr, tree_position);
5068 test_position = tree_position->CreatePositionAtStartOfDocument();
5069 EXPECT_NE(nullptr, test_position);
5070 EXPECT_EQ(root_.id, test_position->anchor_id());
5071}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition().

◆ TEST_F() [257/325]

ui::TEST_F ( AXPositionTest  ,
CreatePositionAtTextBoundaryDocumentStartEndIsIgnored   
)

Definition at line 3776 of file ax_node_position_unittest.cc.

3776 {
3777 // +-root_data
3778 // +-static_text_data_1
3779 // | +-inline_box_data_1 IGNORED
3780 // +-static_text_data_2
3781 // | +-inline_box_data_2
3782 // +-static_text_data_3
3783 // | +-inline_box_data_3
3784 // +-static_text_data_4
3785 // +-inline_box_data_4 IGNORED
3786 constexpr AXNode::AXID ROOT_ID = 1;
3787 constexpr AXNode::AXID STATIC_TEXT1_ID = 2;
3788 constexpr AXNode::AXID STATIC_TEXT2_ID = 3;
3789 constexpr AXNode::AXID STATIC_TEXT3_ID = 4;
3790 constexpr AXNode::AXID STATIC_TEXT4_ID = 5;
3791 constexpr AXNode::AXID INLINE_BOX1_ID = 6;
3792 constexpr AXNode::AXID INLINE_BOX2_ID = 7;
3793 constexpr AXNode::AXID INLINE_BOX3_ID = 8;
3794 constexpr AXNode::AXID INLINE_BOX4_ID = 9;
3795
3796 AXNodeData root_data;
3797 root_data.id = ROOT_ID;
3799
3800 AXNodeData static_text_data_1;
3801 static_text_data_1.id = STATIC_TEXT1_ID;
3802 static_text_data_1.role = ax::mojom::Role::kStaticText;
3803 static_text_data_1.SetName("One");
3804
3805 AXNodeData inline_box_data_1;
3806 inline_box_data_1.id = INLINE_BOX1_ID;
3807 inline_box_data_1.role = ax::mojom::Role::kInlineTextBox;
3808 inline_box_data_1.SetName("One");
3809 inline_box_data_1.AddState(ax::mojom::State::kIgnored);
3810 inline_box_data_1.AddIntListAttribute(
3811 ax::mojom::IntListAttribute::kWordStarts, std::vector<int32_t>{0});
3813 std::vector<int32_t>{3});
3815 INLINE_BOX2_ID);
3816
3817 AXNodeData static_text_data_2;
3818 static_text_data_2.id = STATIC_TEXT2_ID;
3819 static_text_data_2.role = ax::mojom::Role::kStaticText;
3820 static_text_data_2.SetName("Two");
3821
3822 AXNodeData inline_box_data_2;
3823 inline_box_data_2.id = INLINE_BOX2_ID;
3824 inline_box_data_2.role = ax::mojom::Role::kInlineTextBox;
3825 inline_box_data_2.SetName("Two");
3826 inline_box_data_2.AddIntListAttribute(
3827 ax::mojom::IntListAttribute::kWordStarts, std::vector<int32_t>{0});
3828 inline_box_data_2.AddIntListAttribute(ax::mojom::IntListAttribute::kWordEnds,
3829 std::vector<int32_t>{3});
3830 inline_box_data_2.AddIntAttribute(ax::mojom::IntAttribute::kPreviousOnLineId,
3831 INLINE_BOX1_ID);
3832 inline_box_data_2.AddIntAttribute(ax::mojom::IntAttribute::kNextOnLineId,
3833 INLINE_BOX3_ID);
3834
3835 AXNodeData static_text_data_3;
3836 static_text_data_3.id = STATIC_TEXT3_ID;
3837 static_text_data_3.role = ax::mojom::Role::kStaticText;
3838 static_text_data_3.SetName("Three");
3839
3840 AXNodeData inline_box_data_3;
3841 inline_box_data_3.id = INLINE_BOX3_ID;
3842 inline_box_data_3.role = ax::mojom::Role::kInlineTextBox;
3843 inline_box_data_3.SetName("Three");
3844 inline_box_data_3.AddIntListAttribute(
3845 ax::mojom::IntListAttribute::kWordStarts, std::vector<int32_t>{0});
3846 inline_box_data_3.AddIntListAttribute(ax::mojom::IntListAttribute::kWordEnds,
3847 std::vector<int32_t>{5});
3848 inline_box_data_3.AddIntAttribute(ax::mojom::IntAttribute::kPreviousOnLineId,
3849 INLINE_BOX2_ID);
3850 inline_box_data_3.AddIntAttribute(ax::mojom::IntAttribute::kNextOnLineId,
3851 INLINE_BOX4_ID);
3852
3853 AXNodeData static_text_data_4;
3854 static_text_data_4.id = STATIC_TEXT4_ID;
3855 static_text_data_4.role = ax::mojom::Role::kStaticText;
3856 static_text_data_4.SetName("Four");
3857
3858 AXNodeData inline_box_data_4;
3859 inline_box_data_4.id = INLINE_BOX4_ID;
3860 inline_box_data_4.role = ax::mojom::Role::kInlineTextBox;
3861 inline_box_data_4.SetName("Four");
3862 inline_box_data_4.AddState(ax::mojom::State::kIgnored);
3863 inline_box_data_3.AddIntListAttribute(
3864 ax::mojom::IntListAttribute::kWordStarts, std::vector<int32_t>{0});
3865 inline_box_data_3.AddIntListAttribute(ax::mojom::IntListAttribute::kWordEnds,
3866 std::vector<int32_t>{4});
3867 inline_box_data_3.AddIntAttribute(ax::mojom::IntAttribute::kPreviousOnLineId,
3868 INLINE_BOX3_ID);
3869
3870 root_data.child_ids = {static_text_data_1.id, static_text_data_2.id,
3871 static_text_data_3.id, static_text_data_4.id};
3872 static_text_data_1.child_ids = {inline_box_data_1.id};
3873 static_text_data_2.child_ids = {inline_box_data_2.id};
3874 static_text_data_3.child_ids = {inline_box_data_3.id};
3875 static_text_data_4.child_ids = {inline_box_data_4.id};
3876
3877 SetTree(
3878 CreateAXTree({root_data, static_text_data_1, static_text_data_2,
3879 static_text_data_3, static_text_data_4, inline_box_data_1,
3880 inline_box_data_2, inline_box_data_3, inline_box_data_4}));
3881
3882 TestPositionType text_position = AXNodePosition::CreateTextPosition(
3883 GetTreeID(), inline_box_data_2.id, 0 /* text_offset */,
3885 ASSERT_FALSE(text_position->IsIgnored());
3886 TestPositionType 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_3.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_position = text_position->CreatePositionAtTextBoundary(
3896 AXBoundaryBehavior::StopAtLastAnchorBoundary);
3897 ASSERT_NE(nullptr, test_position);
3898 EXPECT_TRUE(test_position->IsTextPosition());
3899 EXPECT_EQ(inline_box_data_2.id, test_position->anchor_id());
3900 EXPECT_EQ(0, test_position->text_offset());
3901 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3902
3903 text_position = AXNodePosition::CreateTextPosition(
3904 GetTreeID(), inline_box_data_3.id, 0 /* text_offset */,
3906 ASSERT_FALSE(text_position->IsIgnored());
3907 test_position = text_position->CreatePositionAtTextBoundary(
3909 AXBoundaryBehavior::StopAtLastAnchorBoundary);
3910 ASSERT_NE(nullptr, test_position);
3911 EXPECT_TRUE(test_position->IsTextPosition());
3912 EXPECT_EQ(inline_box_data_3.id, test_position->anchor_id());
3913 EXPECT_EQ(5, test_position->text_offset());
3914 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3915 test_position = text_position->CreatePositionAtTextBoundary(
3917 AXBoundaryBehavior::StopAtLastAnchorBoundary);
3918 ASSERT_NE(nullptr, test_position);
3919 EXPECT_TRUE(test_position->IsTextPosition());
3920 EXPECT_EQ(inline_box_data_2.id, test_position->anchor_id());
3921 EXPECT_EQ(0, test_position->text_offset());
3922 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
3923}

References ui::AXNodeData::AddIntAttribute(), ui::AXNodeData::AddIntListAttribute(), ui::AXNodeData::AddState(), ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXNodeData::id, ax::mojom::kBackward, ax::mojom::kDownstream, ax::mojom::kForward, ax::mojom::kIgnored, ax::mojom::kInlineTextBox, ax::mojom::kNextOnLineId, ax::mojom::kPreviousOnLineId, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ax::mojom::kWordEnds, ax::mojom::kWordStart, ax::mojom::kWordStarts, ui::AXNodeData::role, ui::AXNodeData::SetName(), and StopAtLastAnchorBoundary.

◆ TEST_F() [258/325]

ui::TEST_F ( AXPositionTest  ,
CreatePreviousCharacterPosition   
)

Definition at line 6261 of file ax_node_position_unittest.cc.

6261 {
6262 TestPositionType text_position = AXNodePosition::CreateTextPosition(
6263 GetTreeID(), inline_box2_.id, 5 /* text_offset */,
6265 ASSERT_NE(nullptr, text_position);
6266 ASSERT_TRUE(text_position->IsTextPosition());
6267
6268 TestPositionType test_position =
6269 text_position->CreatePreviousCharacterPosition(
6270 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6271 EXPECT_NE(nullptr, test_position);
6272 EXPECT_TRUE(test_position->IsTextPosition());
6273 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6274 EXPECT_EQ(5, test_position->text_offset());
6275 test_position = text_position->CreatePreviousCharacterPosition(
6276 AXBoundaryBehavior::CrossBoundary);
6277 EXPECT_NE(nullptr, test_position);
6278 EXPECT_TRUE(test_position->IsTextPosition());
6279 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6280 EXPECT_EQ(4, test_position->text_offset());
6281 test_position = text_position->CreatePreviousCharacterPosition(
6282 AXBoundaryBehavior::StopAtAnchorBoundary);
6283 EXPECT_NE(nullptr, test_position);
6284 EXPECT_TRUE(test_position->IsTextPosition());
6285 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6286 EXPECT_EQ(4, test_position->text_offset());
6287 test_position = text_position->CreatePreviousCharacterPosition(
6288 AXBoundaryBehavior::StopAtLastAnchorBoundary);
6289 EXPECT_NE(nullptr, test_position);
6290 EXPECT_TRUE(test_position->IsTextPosition());
6291 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6292 EXPECT_EQ(4, test_position->text_offset());
6293
6294 text_position = AXNodePosition::CreateTextPosition(
6295 GetTreeID(), inline_box2_.id, 1 /* text_offset */,
6297 ASSERT_NE(nullptr, text_position);
6298 ASSERT_TRUE(text_position->IsTextPosition());
6299
6300 test_position = text_position->CreatePreviousCharacterPosition(
6301 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6302 EXPECT_NE(nullptr, test_position);
6303 EXPECT_TRUE(test_position->IsTextPosition());
6304 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6305 EXPECT_EQ(1, test_position->text_offset());
6306 test_position = text_position->CreatePreviousCharacterPosition(
6307 AXBoundaryBehavior::CrossBoundary);
6308 EXPECT_NE(nullptr, test_position);
6309 EXPECT_TRUE(test_position->IsTextPosition());
6310 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6311 EXPECT_EQ(0, test_position->text_offset());
6312 test_position = text_position->CreatePreviousCharacterPosition(
6313 AXBoundaryBehavior::StopAtAnchorBoundary);
6314 EXPECT_NE(nullptr, test_position);
6315 EXPECT_TRUE(test_position->IsTextPosition());
6316 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6317 EXPECT_EQ(0, test_position->text_offset());
6318 test_position = text_position->CreatePreviousCharacterPosition(
6319 AXBoundaryBehavior::StopAtLastAnchorBoundary);
6320 EXPECT_NE(nullptr, test_position);
6321 EXPECT_TRUE(test_position->IsTextPosition());
6322 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6323 EXPECT_EQ(0, test_position->text_offset());
6324
6325 text_position = AXNodePosition::CreateTextPosition(
6326 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
6328 ASSERT_NE(nullptr, text_position);
6329 ASSERT_TRUE(text_position->IsTextPosition());
6330
6331 test_position = text_position->CreatePreviousCharacterPosition(
6332 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6333 EXPECT_NE(nullptr, test_position);
6334 EXPECT_TRUE(test_position->IsTextPosition());
6335 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
6336 EXPECT_EQ(0, test_position->text_offset());
6337 test_position = text_position->CreatePreviousCharacterPosition(
6338 AXBoundaryBehavior::CrossBoundary);
6339 EXPECT_NE(nullptr, test_position);
6340 EXPECT_TRUE(test_position->IsTextPosition());
6341 EXPECT_EQ(line_break_.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_box2_.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(line_break_.id, test_position->anchor_id());
6354 EXPECT_EQ(0, test_position->text_offset());
6355
6356 text_position = AXNodePosition::CreateTextPosition(
6357 GetTreeID(), inline_box1_.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(inline_box1_.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(inline_box1_.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(inline_box1_.id, test_position->anchor_id());
6383 EXPECT_EQ(0, test_position->text_offset());
6384
6385 text_position = AXNodePosition::CreateTextPosition(
6386 GetTreeID(), check_box_.id, 0 /* 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->IsNullPosition());
6395 test_position = text_position->CreatePreviousCharacterPosition(
6396 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6397 EXPECT_NE(nullptr, test_position);
6398 EXPECT_TRUE(test_position->IsTextPosition());
6399 EXPECT_EQ(check_box_.id, test_position->anchor_id());
6400 EXPECT_EQ(0, test_position->text_offset());
6401 test_position = text_position->CreatePreviousCharacterPosition(
6402 AXBoundaryBehavior::StopAtAnchorBoundary);
6403 EXPECT_NE(nullptr, test_position);
6404 EXPECT_TRUE(test_position->IsTextPosition());
6405 EXPECT_EQ(check_box_.id, test_position->anchor_id());
6406 EXPECT_EQ(0, test_position->text_offset());
6407 test_position = text_position->CreatePreviousCharacterPosition(
6408 AXBoundaryBehavior::StopAtLastAnchorBoundary);
6409 EXPECT_NE(nullptr, test_position);
6410 EXPECT_TRUE(test_position->IsTextPosition());
6411 EXPECT_EQ(check_box_.id, test_position->anchor_id());
6412 EXPECT_EQ(0, test_position->text_offset());
6413
6414 text_position = AXNodePosition::CreateTextPosition(
6415 GetTreeID(), text_field_.id, 1 /* text_offset */,
6417 ASSERT_NE(nullptr, text_position);
6418 ASSERT_TRUE(text_position->IsTextPosition());
6419
6420 test_position = text_position->CreatePreviousCharacterPosition(
6421 AXBoundaryBehavior::CrossBoundary);
6422 EXPECT_NE(nullptr, test_position);
6423 EXPECT_TRUE(test_position->IsTextPosition());
6424 EXPECT_EQ(text_field_.id, test_position->anchor_id());
6425 EXPECT_EQ(0, test_position->text_offset());
6426 // Affinity should have been reset to downstream.
6427 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
6428}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), CrossBoundary, ax::mojom::kDownstream, ax::mojom::kUpstream, StopAtAnchorBoundary, StopAtLastAnchorBoundary, and StopIfAlreadyAtBoundary.

◆ TEST_F() [259/325]

ui::TEST_F ( AXPositionTest  ,
CreatePreviousCharacterPositionAtGraphemeBoundary   
)

Definition at line 6509 of file ax_node_position_unittest.cc.

6509 {
6510#if true
6511 GTEST_SKIP()
6512 << "Skipping, current accessibility library cannot handle grapheme";
6513#else
6514 std::vector<int> text_offsets;
6515 SetTree(CreateMultilingualDocument(&text_offsets));
6516
6517 TestPositionType test_position =
6518 AXNodePosition::CreateTextPosition(GetTreeID(), GetTree()->root()->id(),
6519 text_offsets.back() /* text_offset */,
6521 ASSERT_NE(nullptr, test_position);
6522 ASSERT_TRUE(test_position->IsTextPosition());
6523
6524 for (auto iter = (text_offsets.rbegin() + 1); iter != text_offsets.rend();
6525 ++iter) {
6526 const int text_offset = *iter;
6527 test_position = test_position->CreatePreviousCharacterPosition(
6528 AXBoundaryBehavior::CrossBoundary);
6529 ASSERT_NE(nullptr, test_position);
6530 EXPECT_TRUE(test_position->IsTextPosition());
6531
6532 testing::Message message;
6533 message << "Expecting character boundary at " << text_offset << " in\n"
6534 << *test_position;
6535 SCOPED_TRACE(message);
6536
6537 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
6538 EXPECT_EQ(text_offset, test_position->text_offset());
6539 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
6540 }
6541
6542 test_position = AXNodePosition::CreateTextPosition(
6543 GetTreeID(), GetTree()->root()->id(), 3 /* text_offset */,
6545 test_position = test_position->CreatePreviousCharacterPosition(
6546 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6547 ASSERT_NE(nullptr, test_position);
6548 EXPECT_TRUE(test_position->IsTextPosition());
6549 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
6550 EXPECT_EQ(3, test_position->text_offset());
6551 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
6552
6553 test_position = AXNodePosition::CreateTextPosition(
6554 GetTreeID(), GetTree()->root()->id(), 4 /* text_offset */,
6556 test_position = test_position->CreatePreviousCharacterPosition(
6557 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6558 ASSERT_NE(nullptr, test_position);
6559 EXPECT_TRUE(test_position->IsTextPosition());
6560 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
6561 EXPECT_EQ(3, test_position->text_offset());
6562 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
6563
6564 test_position = AXNodePosition::CreateTextPosition(
6565 GetTreeID(), GetTree()->root()->id(), 9 /* text_offset */,
6567 test_position = test_position->CreatePreviousCharacterPosition(
6568 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6569 ASSERT_NE(nullptr, test_position);
6570 EXPECT_TRUE(test_position->IsTextPosition());
6571 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
6572 EXPECT_EQ(9, test_position->text_offset());
6573 EXPECT_EQ(ax::mojom::TextAffinity::kUpstream, test_position->affinity());
6574
6575 test_position = AXNodePosition::CreateTextPosition(
6576 GetTreeID(), GetTree()->root()->id(), 10 /* text_offset */,
6578 test_position = test_position->CreatePreviousCharacterPosition(
6579 AXBoundaryBehavior::StopIfAlreadyAtBoundary);
6580 ASSERT_NE(nullptr, test_position);
6581 EXPECT_TRUE(test_position->IsTextPosition());
6582 EXPECT_EQ(GetTree()->root()->id(), test_position->anchor_id());
6583 EXPECT_EQ(9, test_position->text_offset());
6584 // Affinity should have been reset to downstream because there was a move.
6585 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity());
6586#endif // true
6587}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), CrossBoundary, ax::mojom::kDownstream, ax::mojom::kUpstream, message, and StopIfAlreadyAtBoundary.

◆ TEST_F() [260/325]

ui::TEST_F ( AXPositionTest  ,
CreatePreviousLeafTextPosition   
)

Definition at line 5390 of file ax_node_position_unittest.cc.

5390 {
5391 TestPositionType text_position = AXNodePosition::CreateTextPosition(
5392 GetTreeID(), inline_box2_.id, 5 /* text_offset */,
5394 ASSERT_NE(nullptr, text_position);
5395 ASSERT_TRUE(text_position->IsTextPosition());
5396 TestPositionType test_position =
5397 text_position->CreatePreviousLeafTextPosition();
5398 EXPECT_NE(nullptr, test_position);
5399 EXPECT_TRUE(test_position->IsTextPosition());
5400 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5401 EXPECT_EQ(line_break_.id, test_position->anchor_id());
5402 EXPECT_EQ(0, test_position->text_offset());
5403
5404 // Create a "before text" tree position on the second line of the text box.
5405 TestPositionType before_text_position = AXNodePosition::CreateTreePosition(
5406 GetTreeID(), inline_box2_.id, AXNodePosition::BEFORE_TEXT);
5407 ASSERT_NE(nullptr, before_text_position);
5408 test_position = before_text_position->CreatePreviousLeafTextPosition();
5409 EXPECT_NE(nullptr, test_position);
5410 EXPECT_TRUE(test_position->IsTextPosition());
5411 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5412 EXPECT_EQ(line_break_.id, test_position->anchor_id());
5413 EXPECT_EQ(0, test_position->text_offset());
5414
5415 test_position = test_position->CreatePreviousLeafTextPosition();
5416 EXPECT_NE(nullptr, test_position);
5417 EXPECT_TRUE(test_position->IsTextPosition());
5418 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5419 EXPECT_EQ(inline_box1_.id, test_position->anchor_id());
5420 EXPECT_EQ(0, test_position->text_offset());
5421
5422 test_position = test_position->CreatePreviousLeafTextPosition();
5423 EXPECT_NE(nullptr, test_position);
5424 EXPECT_TRUE(test_position->IsTextPosition());
5425 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5426 EXPECT_EQ(check_box_.id, test_position->anchor_id());
5427 EXPECT_EQ(0, test_position->text_offset());
5428
5429 test_position = test_position->CreatePreviousLeafTextPosition();
5430 EXPECT_NE(nullptr, test_position);
5431 EXPECT_TRUE(test_position->IsTextPosition());
5432 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5433 EXPECT_EQ(button_.id, test_position->anchor_id());
5434 EXPECT_EQ(0, test_position->text_offset());
5435
5436 test_position = test_position->CreatePreviousLeafTextPosition();
5437 EXPECT_NE(nullptr, test_position);
5438 EXPECT_TRUE(test_position->IsNullPosition());
5439
5440 TestPositionType text_field_position = AXNodePosition::CreateTreePosition(
5441 GetTreeID(), text_field_.id, 2 /* child_index */);
5442 ASSERT_NE(nullptr, text_field_position);
5443 test_position = text_field_position->CreatePreviousLeafTextPosition();
5444 EXPECT_NE(nullptr, test_position);
5445 EXPECT_TRUE(test_position->IsTextPosition());
5446 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5447 EXPECT_EQ(check_box_.id, test_position->anchor_id());
5448 EXPECT_EQ(0, test_position->text_offset());
5449
5450 // The text offset on the root points to the text coming from inside the check
5451 // box.
5452 TestPositionType check_box_position = AXNodePosition::CreateTextPosition(
5453 GetTreeID(), check_box_.id, 0 /* text_offset */,
5455 ASSERT_NE(nullptr, check_box_position);
5456 ASSERT_TRUE(check_box_position->IsTextPosition());
5457 test_position = check_box_position->CreatePreviousLeafTextPosition();
5458 EXPECT_NE(nullptr, test_position);
5459 EXPECT_TRUE(test_position->IsTextPosition());
5460 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5461 EXPECT_EQ(button_.id, test_position->anchor_id());
5462 EXPECT_EQ(0, test_position->text_offset());
5463
5464 // The root text position should resolve to its leaf text position,
5465 // maintaining its text_offset
5466 TestPositionType root_position2 = AXNodePosition::CreateTextPosition(
5467 GetTreeID(), root_.id, 10 /* text_offset */,
5469 ASSERT_NE(nullptr, root_position2);
5470 ASSERT_TRUE(root_position2->IsTextPosition());
5471 test_position = root_position2->CreatePreviousLeafTextPosition();
5472 EXPECT_NE(nullptr, test_position);
5473 EXPECT_TRUE(test_position->IsTextPosition());
5474 EXPECT_EQ(GetTreeID(), test_position->tree_id());
5475 EXPECT_EQ(inline_box2_.id, test_position->anchor_id());
5476 EXPECT_EQ(3, test_position->text_offset());
5477}

References ui::AXPosition< AXNodePosition, AXNode >::BEFORE_TEXT, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), and ax::mojom::kDownstream.

◆ TEST_F() [261/325]

ui::TEST_F ( AXPositionTest  ,
CreatePreviousLeafTreePosition   
)

Definition at line 5538 of file ax_node_position_unittest.cc.

5538 {
5539 TestPositionType inline_box2_position = AXNodePosition::CreateTreePosition(
5540 GetTreeID(), inline_box2_.id, AXNodePosition::BEFORE_TEXT);
5541 ASSERT_TRUE(inline_box2_position->IsTreePosition());
5542
5543 TestPositionType line_break_position = AXNodePosition::CreateTreePosition(
5544 GetTreeID(), line_break_.id, AXNodePosition::BEFORE_TEXT);
5545 TestPositionType inline_box1_position = AXNodePosition::CreateTreePosition(
5546 GetTreeID(), inline_box1_.id, AXNodePosition::BEFORE_TEXT);
5547 TestPositionType checkbox_position = AXNodePosition::CreateTreePosition(
5548 GetTreeID(), check_box_.id, AXNodePosition::BEFORE_TEXT);
5549 TestPositionType button_position = AXNodePosition::CreateTreePosition(
5550 GetTreeID(), button_.id, AXNodePosition::BEFORE_TEXT);
5551
5552 TestPositionType test_position =
5553 inline_box2_position->CreatePreviousLeafTreePosition();
5554 EXPECT_TRUE(test_position->IsTreePosition());
5555 EXPECT_EQ(*test_position, *line_break_position);
5556
5557 test_position = test_position->CreatePreviousLeafTreePosition();
5558 EXPECT_TRUE(test_position->IsTreePosition());
5559 EXPECT_EQ(*test_position, *inline_box1_position);
5560
5561 test_position = test_position->CreatePreviousLeafTreePosition();
5562 EXPECT_TRUE(test_position->IsTreePosition());
5563 EXPECT_EQ(*test_position, *checkbox_position);
5564
5565 test_position = test_position->CreatePreviousLeafTreePosition();
5566 EXPECT_TRUE(test_position->IsTreePosition());
5567 EXPECT_EQ(*test_position, *button_position);
5568
5569 test_position = test_position->CreatePreviousLeafTreePosition();
5570 EXPECT_TRUE(test_position->IsNullPosition());
5571
5572 TestPositionType inline_box2_text_position =
5573 AXNodePosition::CreateTextPosition(GetTreeID(), inline_box2_.id,
5574 2 /* text_offset */,
5576 EXPECT_TRUE(inline_box2_text_position->IsTextPosition());
5577
5578 test_position = inline_box2_text_position->CreatePreviousLeafTreePosition();
5579 EXPECT_TRUE(test_position->IsTreePosition());
5580 EXPECT_EQ(*test_position, *line_break_position);
5581}

References ui::AXPosition< AXNodePosition, AXNode >::BEFORE_TEXT, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), and ax::mojom::kDownstream.

◆ TEST_F() [262/325]

ui::TEST_F ( AXPositionTest  ,
CreatePreviousWordPositionInList   
)

Definition at line 7364 of file ax_node_position_unittest.cc.

7364 {
7365 // This test updates the tree structure to test a specific edge case -
7366 // previous word navigation inside a list with AXListMarkers nodes.
7367 // ++1 kRootWebArea
7368 // ++++2 kList
7369 // ++++++3 kListItem
7370 // ++++++++4 kListMarker
7371 // ++++++++++5 kStaticText
7372 // ++++++++++++6 kInlineTextBox "1. "
7373 // ++++++++7 kStaticText
7374 // ++++++++++8 kInlineTextBox "first item"
7375 // ++++++9 kListItem
7376 // ++++++++10 kListMarker
7377 // +++++++++++11 kStaticText
7378 // ++++++++++++++12 kInlineTextBox "2. "
7379 // ++++++++13 kStaticText
7380 // ++++++++++14 kInlineTextBox "second item"
7381 AXNodeData root;
7382 AXNodeData list;
7383 AXNodeData list_item1;
7384 AXNodeData list_item2;
7385 AXNodeData list_marker1;
7386 AXNodeData list_marker2;
7387 AXNodeData inline_box1;
7388 AXNodeData inline_box2;
7389 AXNodeData inline_box3;
7390 AXNodeData inline_box4;
7391 AXNodeData static_text1;
7392 AXNodeData static_text2;
7393 AXNodeData static_text3;
7394 AXNodeData static_text4;
7395
7396 root.id = 1;
7397 list.id = 2;
7398 list_item1.id = 3;
7399 list_marker1.id = 4;
7400 static_text1.id = 5;
7401 inline_box1.id = 6;
7402 static_text2.id = 7;
7403 inline_box2.id = 8;
7404 list_item2.id = 9;
7405 list_marker2.id = 10;
7406 static_text3.id = 11;
7407 inline_box3.id = 12;
7408 static_text4.id = 13;
7409 inline_box4.id = 14;
7410
7412 root.child_ids = {list.id};
7413
7415 list.child_ids = {list_item1.id, list_item2.id};
7416
7417 list_item1.role = ax::mojom::Role::kListItem;
7418 list_item1.child_ids = {list_marker1.id, static_text2.id};
7420 true);
7421
7422 list_marker1.role = ax::mojom::Role::kListMarker;
7423 list_marker1.child_ids = {static_text1.id};
7424
7425 static_text1.role = ax::mojom::Role::kStaticText;
7426 static_text1.SetName("1. ");
7427 static_text1.child_ids = {inline_box1.id};
7428
7430 inline_box1.SetName("1. ");
7432 std::vector<int32_t>{0});
7434 std::vector<int32_t>{3});
7435
7436 static_text2.role = ax::mojom::Role::kStaticText;
7437 static_text2.SetName("first item");
7438 static_text2.child_ids = {inline_box2.id};
7439
7441 inline_box2.SetName("first item");
7443 std::vector<int32_t>{0, 6});
7445 std::vector<int32_t>{5});
7446
7447 list_item2.role = ax::mojom::Role::kListItem;
7448 list_item2.child_ids = {list_marker2.id, static_text4.id};
7450 true);
7451
7452 list_marker2.role = ax::mojom::Role::kListMarker;
7453 list_marker2.child_ids = {static_text3.id};
7454
7455 static_text3.role = ax::mojom::Role::kStaticText;
7456 static_text3.SetName("2. ");
7457 static_text3.child_ids = {inline_box3.id};
7458
7460 inline_box3.SetName("2. ");
7462 std::vector<int32_t>{0});
7464 std::vector<int32_t>{3});
7465
7466 static_text4.role = ax::mojom::Role::kStaticText;
7467 static_text4.SetName("second item");
7468 static_text4.child_ids = {inline_box4.id};
7469
7471 inline_box4.SetName("second item");
7473 std::vector<int32_t>{0, 7});
7475 std::vector<int32_t>{6});
7476
7477 SetTree(CreateAXTree({root, list, list_item1, list_marker1, static_text1,
7478 inline_box1, static_text2, inline_box2, list_item2,
7479 list_marker2, static_text3, inline_box3, static_text4,
7480 inline_box4}));
7481
7482 TestPositionType text_position = AXNodePosition::CreateTextPosition(
7483 GetTreeID(), inline_box4.id, 11 /* text_offset */,
7485 ASSERT_NE(nullptr, text_position);
7486 ASSERT_TRUE(text_position->IsTextPosition());
7487 ASSERT_EQ(inline_box4.id, text_position->anchor_id());
7488 ASSERT_EQ(11, text_position->text_offset());
7489
7490 // "1. first item\n2. second <i>tem"
7491 text_position = text_position->CreatePreviousWordStartPosition(
7492 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7493 ASSERT_NE(nullptr, text_position);
7494 ASSERT_TRUE(text_position->IsTextPosition());
7495 ASSERT_EQ(inline_box4.id, text_position->anchor_id());
7496 ASSERT_EQ(7, text_position->text_offset());
7497
7498 // "1. first item\n2. <s>econd item"
7499 text_position = text_position->CreatePreviousWordStartPosition(
7500 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7501 ASSERT_NE(nullptr, text_position);
7502 ASSERT_TRUE(text_position->IsTextPosition());
7503 ASSERT_EQ(inline_box4.id, text_position->anchor_id());
7504 ASSERT_EQ(0, text_position->text_offset());
7505
7506 // "1. first item\n<2>. second item"
7507 text_position = text_position->CreatePreviousWordStartPosition(
7508 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7509 ASSERT_NE(nullptr, text_position);
7510 ASSERT_TRUE(text_position->IsTextPosition());
7511 ASSERT_EQ(inline_box3.id, text_position->anchor_id());
7512 ASSERT_EQ(0, text_position->text_offset());
7513
7514 // "1. first <i>tem\n2. <s>econd item"
7515 text_position = text_position->CreatePreviousWordStartPosition(
7516 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7517 ASSERT_NE(nullptr, text_position);
7518 ASSERT_TRUE(text_position->IsTextPosition());
7519 ASSERT_EQ(inline_box2.id, text_position->anchor_id());
7520 ASSERT_EQ(6, text_position->text_offset());
7521
7522 // "1. <f>irst item\n2. second item"
7523 text_position = text_position->CreatePreviousWordStartPosition(
7524 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7525 ASSERT_NE(nullptr, text_position);
7526 ASSERT_TRUE(text_position->IsTextPosition());
7527 ASSERT_EQ(inline_box2.id, text_position->anchor_id());
7528 ASSERT_EQ(0, text_position->text_offset());
7529
7530 // "<1>. first item\n2. second item"
7531 text_position = text_position->CreatePreviousWordStartPosition(
7532 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7533 ASSERT_NE(nullptr, text_position);
7534 ASSERT_TRUE(text_position->IsTextPosition());
7535 ASSERT_EQ(inline_box1.id, text_position->anchor_id());
7536 ASSERT_EQ(0, text_position->text_offset());
7537}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::AddIntListAttribute(), ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kInlineTextBox, ax::mojom::kIsLineBreakingObject, ax::mojom::kList, ax::mojom::kListItem, ax::mojom::kListMarker, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ax::mojom::kWordEnds, ax::mojom::kWordStarts, ui::AXNodeData::role, ui::AXNodeData::SetName(), and StopAtLastAnchorBoundary.

◆ TEST_F() [263/325]

ui::TEST_F ( AXPositionTest  ,
EmptyObjectReplacedByCharacterTextNavigation   
)

Definition at line 7539 of file ax_node_position_unittest.cc.

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

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::AddIntListAttribute(), ui::AXNodeData::AddState(), ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), CrossBoundary, g_ax_embedded_object_behavior, ui::AXNodeData::id, ax::mojom::kButton, ax::mojom::kDownstream, ui::AXPosition< AXNodePosition, AXNode >::kEmbeddedCharacter, kExposeCharacter, ax::mojom::kGenericContainer, ax::mojom::kGroup, ax::mojom::kHeading, ax::mojom::kIgnored, ax::mojom::kInlineTextBox, ax::mojom::kIsLineBreakingObject, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ax::mojom::kWordEnds, ax::mojom::kWordStarts, ui::AXNodeData::role, ui::AXNodeData::SetName(), StopAtLastAnchorBoundary, and StopIfAlreadyAtBoundary.

◆ TEST_F() [264/325]

ui::TEST_F ( AXPositionTest  ,
GetMaxTextOffsetAndGetTextWithGeneratedContent   
)

Definition at line 1084 of file ax_node_position_unittest.cc.

1084 {
1085 // ++1 kRootWebArea
1086 // ++++2 kTextField
1087 // ++++++3 kStaticText
1088 // ++++++++4 kInlineTextBox
1089 // ++++++5 kStaticText
1090 // ++++++++6 kInlineTextBox
1091 AXNodeData root_1;
1092 AXNodeData text_field_2;
1093 AXNodeData static_text_3;
1094 AXNodeData inline_box_4;
1095 AXNodeData static_text_5;
1096 AXNodeData inline_box_6;
1097
1098 root_1.id = 1;
1099 text_field_2.id = 2;
1100 static_text_3.id = 3;
1101 inline_box_4.id = 4;
1102 static_text_5.id = 5;
1103 inline_box_6.id = 6;
1104
1106 root_1.child_ids = {text_field_2.id};
1107
1108 text_field_2.role = ax::mojom::Role::kGroup;
1109 text_field_2.SetValue("3.14");
1110 text_field_2.child_ids = {static_text_3.id, static_text_5.id};
1111
1112 static_text_3.role = ax::mojom::Role::kStaticText;
1113 static_text_3.SetName("Placeholder from generated content");
1114 static_text_3.child_ids = {inline_box_4.id};
1115
1117 inline_box_4.SetName("Placeholder from generated content");
1118
1119 static_text_5.role = ax::mojom::Role::kStaticText;
1120 static_text_5.SetName("3.14");
1121 static_text_5.child_ids = {inline_box_6.id};
1122
1124 inline_box_6.SetName("3.14");
1125
1126 SetTree(CreateAXTree({root_1, text_field_2, static_text_3, inline_box_4,
1127 static_text_5, inline_box_6}));
1128
1129 TestPositionType text_position = AXNodePosition::CreateTextPosition(
1130 GetTreeID(), text_field_2.id, 0 /* text_offset */,
1132 ASSERT_NE(nullptr, text_position);
1133 EXPECT_TRUE(text_position->IsTextPosition());
1134 EXPECT_EQ(38, text_position->MaxTextOffset());
1135 EXPECT_EQ(u"Placeholder from generated content3.14",
1136 text_position->GetText());
1137}

References ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kGroup, ax::mojom::kInlineTextBox, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXNodeData::role, ui::AXNodeData::SetName(), and ui::AXNodeData::SetValue().

◆ TEST_F() [265/325]

ui::TEST_F ( AXPositionTest  ,
GetMaxTextOffsetFromButton   
)

Definition at line 987 of file ax_node_position_unittest.cc.

987 {
988 TestPositionType text_position = AXNodePosition::CreateTextPosition(
989 GetTreeID(), button_.id, 0 /* text_offset */,
991 ASSERT_NE(nullptr, text_position);
992 ASSERT_TRUE(text_position->IsTextPosition());
993 ASSERT_EQ(0, text_position->MaxTextOffset());
994}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kUpstream.

◆ TEST_F() [266/325]

ui::TEST_F ( AXPositionTest  ,
GetMaxTextOffsetFromCheckbox   
)

Definition at line 996 of file ax_node_position_unittest.cc.

996 {
997 TestPositionType text_position = AXNodePosition::CreateTextPosition(
998 GetTreeID(), check_box_.id, 0 /* text_offset */,
1000 ASSERT_NE(nullptr, text_position);
1001 ASSERT_TRUE(text_position->IsTextPosition());
1002 ASSERT_EQ(0, text_position->MaxTextOffset());
1003}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kUpstream.

◆ TEST_F() [267/325]

ui::TEST_F ( AXPositionTest  ,
GetMaxTextOffsetFromInlineTextBox   
)

Definition at line 1023 of file ax_node_position_unittest.cc.

1023 {
1024 TestPositionType text_position = AXNodePosition::CreateTextPosition(
1025 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
1027 ASSERT_NE(nullptr, text_position);
1028 ASSERT_TRUE(text_position->IsTextPosition());
1029 ASSERT_EQ(6, text_position->MaxTextOffset());
1030}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kUpstream.

◆ TEST_F() [268/325]

ui::TEST_F ( AXPositionTest  ,
GetMaxTextOffsetFromLineBreak   
)

Definition at line 1032 of file ax_node_position_unittest.cc.

1032 {
1033 TestPositionType text_position = AXNodePosition::CreateTextPosition(
1034 GetTreeID(), line_break_.id, 0 /* text_offset */,
1036 ASSERT_NE(nullptr, text_position);
1037 ASSERT_TRUE(text_position->IsTextPosition());
1038 ASSERT_EQ(1, text_position->MaxTextOffset());
1039}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kUpstream.

◆ TEST_F() [269/325]

ui::TEST_F ( AXPositionTest  ,
GetMaxTextOffsetFromNullPosition   
)

Definition at line 971 of file ax_node_position_unittest.cc.

971 {
972 TestPositionType text_position = AXNodePosition::CreateNullPosition();
973 ASSERT_NE(nullptr, text_position);
974 ASSERT_TRUE(text_position->IsNullPosition());
975 ASSERT_EQ(AXNodePosition::INVALID_OFFSET, text_position->MaxTextOffset());
976}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition(), and ui::AXPosition< AXNodePosition, AXNode >::INVALID_OFFSET.

◆ TEST_F() [270/325]

ui::TEST_F ( AXPositionTest  ,
GetMaxTextOffsetFromRoot   
)

Definition at line 978 of file ax_node_position_unittest.cc.

978 {
979 TestPositionType text_position = AXNodePosition::CreateTextPosition(
980 GetTreeID(), root_.id, 0 /* text_offset */,
982 ASSERT_NE(nullptr, text_position);
983 ASSERT_TRUE(text_position->IsTextPosition());
984 ASSERT_EQ(13, text_position->MaxTextOffset());
985}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kUpstream.

◆ TEST_F() [271/325]

ui::TEST_F ( AXPositionTest  ,
GetMaxTextOffsetFromStaticText   
)

Definition at line 1014 of file ax_node_position_unittest.cc.

1014 {
1015 TestPositionType text_position = AXNodePosition::CreateTextPosition(
1016 GetTreeID(), static_text1_.id, 0 /* text_offset */,
1018 ASSERT_NE(nullptr, text_position);
1019 ASSERT_TRUE(text_position->IsTextPosition());
1020 ASSERT_EQ(6, text_position->MaxTextOffset());
1021}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kUpstream.

◆ TEST_F() [272/325]

ui::TEST_F ( AXPositionTest  ,
GetMaxTextOffsetFromTextfield   
)

Definition at line 1005 of file ax_node_position_unittest.cc.

1005 {
1006 TestPositionType text_position = AXNodePosition::CreateTextPosition(
1007 GetTreeID(), text_field_.id, 0 /* text_offset */,
1009 ASSERT_NE(nullptr, text_position);
1010 ASSERT_TRUE(text_position->IsTextPosition());
1011 ASSERT_EQ(13, text_position->MaxTextOffset());
1012}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kUpstream.

◆ TEST_F() [273/325]

ui::TEST_F ( AXPositionTest  ,
GetMaxTextOffsetUpdate   
)

Definition at line 1041 of file ax_node_position_unittest.cc.

1041 {
1042 AXNodeData root_data;
1043 root_data.id = 1;
1045
1046 AXNodeData text_data;
1047 text_data.id = 2;
1049 text_data.SetName("some text");
1050
1051 AXNodeData more_text_data;
1052 more_text_data.id = 3;
1053 more_text_data.role = ax::mojom::Role::kStaticText;
1054 more_text_data.SetName("more text");
1055
1056 root_data.child_ids = {2, 3};
1057
1058 SetTree(CreateAXTree({root_data, text_data, more_text_data}));
1059
1060 AssertTextLengthEquals(GetTree(), text_data.id, 9);
1061 AssertTextLengthEquals(GetTree(), root_data.id, 18);
1062
1063 text_data.SetName("Adjusted line 1");
1064 SetTree(CreateAXTree({root_data, text_data, more_text_data}));
1065
1066 AssertTextLengthEquals(GetTree(), text_data.id, 15);
1067 AssertTextLengthEquals(GetTree(), root_data.id, 24);
1068
1069 // Value should override name
1070 text_data.SetValue("Value should override name");
1071 SetTree(CreateAXTree({root_data, text_data, more_text_data}));
1072
1073 AssertTextLengthEquals(GetTree(), text_data.id, 26);
1074 AssertTextLengthEquals(GetTree(), root_data.id, 35);
1075
1076 // An empty value should fall back to name
1077 text_data.SetValue("");
1078 SetTree(CreateAXTree({root_data, text_data, more_text_data}));
1079
1080 AssertTextLengthEquals(GetTree(), text_data.id, 15);
1081 AssertTextLengthEquals(GetTree(), root_data.id, 24);
1082}

References ui::AXNodeData::child_ids, ui::AXNodeData::id, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXNodeData::role, ui::AXNodeData::SetName(), and ui::AXNodeData::SetValue().

◆ TEST_F() [274/325]

ui::TEST_F ( AXPositionTest  ,
GetTextFromButton   
)

Definition at line 917 of file ax_node_position_unittest.cc.

917 {
918 TestPositionType text_position = AXNodePosition::CreateTextPosition(
919 GetTreeID(), button_.id, 0 /* text_offset */,
921 ASSERT_NE(nullptr, text_position);
922 ASSERT_TRUE(text_position->IsTextPosition());
923 ASSERT_EQ(u"", text_position->GetText());
924}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kUpstream.

◆ TEST_F() [275/325]

ui::TEST_F ( AXPositionTest  ,
GetTextFromCheckbox   
)

Definition at line 926 of file ax_node_position_unittest.cc.

926 {
927 TestPositionType text_position = AXNodePosition::CreateTextPosition(
928 GetTreeID(), check_box_.id, 0 /* text_offset */,
930 ASSERT_NE(nullptr, text_position);
931 ASSERT_TRUE(text_position->IsTextPosition());
932 ASSERT_EQ(u"", text_position->GetText());
933}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kUpstream.

◆ TEST_F() [276/325]

ui::TEST_F ( AXPositionTest  ,
GetTextFromInlineTextBox   
)

Definition at line 953 of file ax_node_position_unittest.cc.

953 {
954 TestPositionType text_position = AXNodePosition::CreateTextPosition(
955 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
957 ASSERT_NE(nullptr, text_position);
958 ASSERT_TRUE(text_position->IsTextPosition());
959 ASSERT_EQ(u"Line 1", text_position->GetText());
960}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kUpstream.

◆ TEST_F() [277/325]

ui::TEST_F ( AXPositionTest  ,
GetTextFromLineBreak   
)

Definition at line 962 of file ax_node_position_unittest.cc.

962 {
963 TestPositionType text_position = AXNodePosition::CreateTextPosition(
964 GetTreeID(), line_break_.id, 0 /* text_offset */,
966 ASSERT_NE(nullptr, text_position);
967 ASSERT_TRUE(text_position->IsTextPosition());
968 ASSERT_EQ(u"\n", text_position->GetText());
969}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kUpstream.

◆ TEST_F() [278/325]

ui::TEST_F ( AXPositionTest  ,
GetTextFromNullPosition   
)

Definition at line 901 of file ax_node_position_unittest.cc.

901 {
902 TestPositionType text_position = AXNodePosition::CreateNullPosition();
903 ASSERT_NE(nullptr, text_position);
904 ASSERT_TRUE(text_position->IsNullPosition());
905 ASSERT_EQ(u"", text_position->GetText());
906}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition().

◆ TEST_F() [279/325]

ui::TEST_F ( AXPositionTest  ,
GetTextFromRoot   
)

Definition at line 908 of file ax_node_position_unittest.cc.

908 {
909 TestPositionType text_position = AXNodePosition::CreateTextPosition(
910 GetTreeID(), root_.id, 0 /* text_offset */,
912 ASSERT_NE(nullptr, text_position);
913 ASSERT_TRUE(text_position->IsTextPosition());
914 ASSERT_EQ(u"Line 1\nLine 2", text_position->GetText());
915}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kUpstream.

◆ TEST_F() [280/325]

ui::TEST_F ( AXPositionTest  ,
GetTextFromStaticText   
)

Definition at line 944 of file ax_node_position_unittest.cc.

944 {
945 TestPositionType text_position = AXNodePosition::CreateTextPosition(
946 GetTreeID(), static_text1_.id, 0 /* text_offset */,
948 ASSERT_NE(nullptr, text_position);
949 ASSERT_TRUE(text_position->IsTextPosition());
950 ASSERT_EQ(u"Line 1", text_position->GetText());
951}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kUpstream.

◆ TEST_F() [281/325]

ui::TEST_F ( AXPositionTest  ,
GetTextFromTextField   
)

Definition at line 935 of file ax_node_position_unittest.cc.

935 {
936 TestPositionType text_position = AXNodePosition::CreateTextPosition(
937 GetTreeID(), text_field_.id, 0 /* text_offset */,
939 ASSERT_NE(nullptr, text_position);
940 ASSERT_TRUE(text_position->IsTextPosition());
941 ASSERT_EQ(u"Line 1\nLine 2", text_position->GetText());
942}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kUpstream.

◆ TEST_F() [282/325]

ui::TEST_F ( AXPositionTest  ,
IsIgnored   
)

Definition at line 751 of file ax_node_position_unittest.cc.

751 {
752 EXPECT_FALSE(AXNodePosition::CreateNullPosition()->IsIgnored());
753
754 // We now need to update the tree structure to test ignored tree and text
755 // positions.
756 AXNodeData root_data;
757 root_data.id = 1;
759
760 AXNodeData static_text_data_1;
761 static_text_data_1.id = 2;
762 static_text_data_1.role = ax::mojom::Role::kStaticText;
763 static_text_data_1.SetName("One");
764
765 AXNodeData inline_box_data_1;
766 inline_box_data_1.id = 3;
767 inline_box_data_1.role = ax::mojom::Role::kInlineTextBox;
768 inline_box_data_1.SetName("One");
769 inline_box_data_1.AddState(ax::mojom::State::kIgnored);
770
771 AXNodeData container_data;
772 container_data.id = 4;
774 container_data.AddState(ax::mojom::State::kIgnored);
775
776 AXNodeData static_text_data_2;
777 static_text_data_2.id = 5;
778 static_text_data_2.role = ax::mojom::Role::kStaticText;
779 static_text_data_2.SetName("Two");
780
781 AXNodeData inline_box_data_2;
782 inline_box_data_2.id = 6;
783 inline_box_data_2.role = ax::mojom::Role::kInlineTextBox;
784 inline_box_data_2.SetName("Two");
785
786 static_text_data_1.child_ids = {inline_box_data_1.id};
787 container_data.child_ids = {static_text_data_2.id};
788 static_text_data_2.child_ids = {inline_box_data_2.id};
789 root_data.child_ids = {static_text_data_1.id, container_data.id};
790
791 SetTree(
792 CreateAXTree({root_data, static_text_data_1, inline_box_data_1,
793 container_data, static_text_data_2, inline_box_data_2}));
794
795 //
796 // Text positions.
797 //
798
799 TestPositionType text_position_1 = AXNodePosition::CreateTextPosition(
800 GetTreeID(), root_data.id, 0 /* text_offset */,
802 ASSERT_TRUE(text_position_1->IsTextPosition());
803 // Since the leaf node containing the text that is pointed to is ignored, this
804 // position should be ignored.
805 EXPECT_TRUE(text_position_1->IsIgnored());
806
807 // Create a text position before the letter "e" in "One".
808 TestPositionType text_position_2 = AXNodePosition::CreateTextPosition(
809 GetTreeID(), root_data.id, 2 /* text_offset */,
811 ASSERT_TRUE(text_position_2->IsTextPosition());
812 // Same as above.
813 EXPECT_TRUE(text_position_2->IsIgnored());
814
815 // Create a text position before the letter "T" in "Two".
816 TestPositionType text_position_3 = AXNodePosition::CreateTextPosition(
817 GetTreeID(), root_data.id, 3 /* text_offset */,
819 ASSERT_TRUE(text_position_3->IsTextPosition());
820 // Since the leaf node containing the text that is pointed to is not ignored,
821 // but only a generic container that is in between this position and the leaf
822 // node, this position should not be ignored.
823 EXPECT_FALSE(text_position_3->IsIgnored());
824
825 // Create a text position before the letter "w" in "Two".
826 TestPositionType text_position_4 = AXNodePosition::CreateTextPosition(
827 GetTreeID(), root_data.id, 4 /* text_offset */,
829 ASSERT_TRUE(text_position_4->IsTextPosition());
830 // Same as above.
831 EXPECT_FALSE(text_position_4->IsIgnored());
832
833 // But a text position on the ignored generic container itself, should be
834 // ignored.
835 TestPositionType text_position_5 = AXNodePosition::CreateTextPosition(
836 GetTreeID(), container_data.id, 0 /* text_offset */,
838 ASSERT_TRUE(text_position_5->IsTextPosition());
839 EXPECT_TRUE(text_position_5->IsIgnored());
840
841 // Whilst a text position on its static text child should not be ignored since
842 // there is nothing ignore below the generic container.
843 TestPositionType text_position_6 = AXNodePosition::CreateTextPosition(
844 GetTreeID(), static_text_data_2.id, 0 /* text_offset */,
846 ASSERT_TRUE(text_position_6->IsTextPosition());
847 EXPECT_FALSE(text_position_6->IsIgnored());
848
849 // A text position on an ignored leaf node should be ignored.
850 TestPositionType text_position_7 = AXNodePosition::CreateTextPosition(
851 GetTreeID(), inline_box_data_1.id, 1 /* text_offset */,
853 ASSERT_TRUE(text_position_7->IsTextPosition());
854 EXPECT_TRUE(text_position_7->IsIgnored());
855
856 //
857 // Tree positions.
858 //
859
860 // A "before children" position on the root should not be ignored, despite the
861 // fact that the leaf equivalent position is, because we can always adjust to
862 // an unignored position if asked to find the leaf equivalent unignored
863 // position.
864 TestPositionType tree_position_1 = AXNodePosition::CreateTreePosition(
865 GetTreeID(), root_data.id, 0 /* child_index */);
866 ASSERT_TRUE(tree_position_1->IsTreePosition());
867 EXPECT_FALSE(tree_position_1->IsIgnored());
868
869 // A tree position pointing to an ignored child node should be ignored.
870 TestPositionType tree_position_2 = AXNodePosition::CreateTreePosition(
871 GetTreeID(), root_data.id, 1 /* child_index */);
872 ASSERT_TRUE(tree_position_2->IsTreePosition());
873 EXPECT_TRUE(tree_position_2->IsIgnored());
874
875 // An "after text" tree position on an ignored leaf node should be ignored.
876 TestPositionType tree_position_3 = AXNodePosition::CreateTreePosition(
877 GetTreeID(), inline_box_data_1.id, 0 /* child_index */);
878 ASSERT_TRUE(tree_position_3->IsTreePosition());
879 EXPECT_TRUE(tree_position_3->IsIgnored());
880
881 // A "before text" tree position on an ignored leaf node should be ignored.
882 TestPositionType tree_position_4 = AXNodePosition::CreateTreePosition(
883 GetTreeID(), inline_box_data_1.id, AXNodePosition::BEFORE_TEXT);
884 ASSERT_TRUE(tree_position_4->IsTreePosition());
885 EXPECT_TRUE(tree_position_4->IsIgnored());
886
887 // An "after children" tree position on the root node, where the last child is
888 // ignored, should be ignored.
889 TestPositionType tree_position_5 = AXNodePosition::CreateTreePosition(
890 GetTreeID(), root_data.id, 2 /* child_index */);
891 ASSERT_TRUE(tree_position_5->IsTreePosition());
892 EXPECT_TRUE(tree_position_5->IsIgnored());
893
894 // A "before text" position on an unignored node should not be ignored.
895 TestPositionType tree_position_6 = AXNodePosition::CreateTreePosition(
896 GetTreeID(), static_text_data_1.id, AXNodePosition::BEFORE_TEXT);
897 ASSERT_TRUE(tree_position_6->IsTreePosition());
898 EXPECT_FALSE(tree_position_6->IsIgnored());
899}

References ui::AXNodeData::AddState(), ui::AXPosition< AXNodePosition, AXNode >::BEFORE_TEXT, ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kGenericContainer, ax::mojom::kIgnored, ax::mojom::kInlineTextBox, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ TEST_F() [283/325]

ui::TEST_F ( AXPositionTest  ,
LowestCommonAncestor   
)

Definition at line 2843 of file ax_node_position_unittest.cc.

2843 {
2844 TestPositionType null_position = AXNodePosition::CreateNullPosition();
2845 ASSERT_NE(nullptr, null_position);
2846 // An "after children" position.
2847 TestPositionType root_position = AXNodePosition::CreateTreePosition(
2848 GetTreeID(), root_.id, 3 /* child_index */);
2849 ASSERT_NE(nullptr, root_position);
2850 // A "before text" position.
2851 TestPositionType button_position = AXNodePosition::CreateTreePosition(
2852 GetTreeID(), button_.id, AXNodePosition::BEFORE_TEXT);
2853 ASSERT_NE(nullptr, button_position);
2854 TestPositionType text_field_position = AXNodePosition::CreateTreePosition(
2855 GetTreeID(), text_field_.id, 2 /* child_index */);
2856 ASSERT_NE(nullptr, text_field_position);
2857 TestPositionType static_text1_position = AXNodePosition::CreateTreePosition(
2858 GetTreeID(), static_text1_.id, 0 /* child_index */);
2859 ASSERT_NE(nullptr, static_text1_position);
2860 TestPositionType static_text2_position = AXNodePosition::CreateTreePosition(
2861 GetTreeID(), static_text2_.id, 0 /* child_index */);
2862 ASSERT_NE(nullptr, static_text2_position);
2863 TestPositionType inline_box1_position = AXNodePosition::CreateTextPosition(
2864 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
2866 ASSERT_NE(nullptr, inline_box1_position);
2867 ASSERT_TRUE(inline_box1_position->IsTextPosition());
2868 TestPositionType inline_box2_position = AXNodePosition::CreateTextPosition(
2869 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
2871 ASSERT_NE(nullptr, inline_box2_position);
2872 ASSERT_TRUE(inline_box2_position->IsTextPosition());
2873
2874 TestPositionType test_position =
2875 root_position->LowestCommonAncestor(*null_position.get());
2876 EXPECT_NE(nullptr, test_position);
2877 EXPECT_TRUE(test_position->IsNullPosition());
2878
2879 test_position = root_position->LowestCommonAncestor(*root_position.get());
2880 EXPECT_NE(nullptr, test_position);
2881 EXPECT_TRUE(test_position->IsTreePosition());
2882 EXPECT_EQ(root_.id, test_position->anchor_id());
2883 // The child index should be for an "after children" position, i.e. it should
2884 // be unchanged.
2885 EXPECT_EQ(3, test_position->child_index());
2886
2887 test_position =
2888 button_position->LowestCommonAncestor(*text_field_position.get());
2889 EXPECT_NE(nullptr, test_position);
2890 EXPECT_TRUE(test_position->IsTreePosition());
2891 EXPECT_EQ(root_.id, test_position->anchor_id());
2892 // The child index should point to the button.
2893 EXPECT_EQ(0, test_position->child_index());
2894
2895 test_position =
2896 static_text2_position->LowestCommonAncestor(*static_text1_position.get());
2897 EXPECT_NE(nullptr, test_position);
2898 EXPECT_TRUE(test_position->IsTreePosition());
2899 EXPECT_EQ(text_field_.id, test_position->anchor_id());
2900 // The child index should point to the second static text node.
2901 EXPECT_EQ(2, test_position->child_index());
2902
2903 test_position =
2904 static_text1_position->LowestCommonAncestor(*text_field_position.get());
2905 EXPECT_NE(nullptr, test_position);
2906 EXPECT_TRUE(test_position->IsTreePosition());
2907 EXPECT_EQ(text_field_.id, test_position->anchor_id());
2908 // The child index should point to the first static text node.
2909 EXPECT_EQ(0, test_position->child_index());
2910
2911 test_position =
2912 inline_box1_position->LowestCommonAncestor(*inline_box2_position.get());
2913 EXPECT_NE(nullptr, test_position);
2914 EXPECT_TRUE(test_position->IsTextPosition());
2915 EXPECT_EQ(text_field_.id, test_position->anchor_id());
2916 EXPECT_EQ(0, test_position->text_offset());
2917
2918 test_position =
2919 inline_box2_position->LowestCommonAncestor(*inline_box1_position.get());
2920 EXPECT_NE(nullptr, test_position);
2921 EXPECT_TRUE(test_position->IsTextPosition());
2922 EXPECT_EQ(text_field_.id, test_position->anchor_id());
2923 // The text offset should point to the second line.
2924 EXPECT_EQ(7, test_position->text_offset());
2925}

References ui::AXPosition< AXNodePosition, AXNode >::BEFORE_TEXT, ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), ax::mojom::kDownstream, and ax::mojom::kUpstream.

◆ TEST_F() [284/325]

ui::TEST_F ( AXPositionTest  ,
MoveByFormatWithIgnoredNodes   
)

Definition at line 4369 of file ax_node_position_unittest.cc.

4369 {
4370 // ++1 kRootWebArea
4371 // ++++2 kGenericContainer
4372 // ++++++3 kButton
4373 // ++++++++4 kStaticText
4374 // ++++++++++5 kInlineTextBox
4375 // ++++++++6 kSvgRoot ignored
4376 // ++++++++++7 kGenericContainer ignored
4377 // ++++8 kGenericContainer
4378 // ++++++9 kHeading
4379 // ++++++++10 kStaticText
4380 // ++++++++++11 kInlineTextBox
4381 // ++++++12 kStaticText
4382 // ++++++++13 kInlineTextBox
4383 // ++++++14 kGenericContainer ignored
4384 // ++++15 kGenericContainer
4385 // ++++++16 kHeading
4386 // ++++++++17 kStaticText
4387 // ++++++++++18 kInlineTextBox
4388 // ++++19 kGenericContainer
4389 // ++++++20 kGenericContainer ignored
4390 // ++++++21 kStaticText
4391 // ++++++++22 kInlineTextBox
4392 // ++++++23 kHeading
4393 // ++++++++24 kStaticText
4394 // ++++++++++25 kInlineTextBox
4395 AXNodeData root_1;
4396 AXNodeData generic_container_2;
4397 AXNodeData button_3;
4398 AXNodeData static_text_4;
4399 AXNodeData inline_box_5;
4400 AXNodeData svg_root_6;
4401 AXNodeData generic_container_7;
4402 AXNodeData generic_container_8;
4403 AXNodeData heading_9;
4404 AXNodeData static_text_10;
4405 AXNodeData inline_box_11;
4406 AXNodeData static_text_12;
4407 AXNodeData inline_box_13;
4408 AXNodeData generic_container_14;
4409 AXNodeData generic_container_15;
4410 AXNodeData heading_16;
4411 AXNodeData static_text_17;
4412 AXNodeData inline_box_18;
4413 AXNodeData generic_container_19;
4414 AXNodeData generic_container_20;
4415 AXNodeData static_text_21;
4416 AXNodeData inline_box_22;
4417 AXNodeData heading_23;
4418 AXNodeData static_text_24;
4419 AXNodeData inline_box_25;
4420
4421 root_1.id = 1;
4422 generic_container_2.id = 2;
4423 button_3.id = 3;
4424 static_text_4.id = 4;
4425 inline_box_5.id = 5;
4426 svg_root_6.id = 6;
4427 generic_container_7.id = 7;
4428 generic_container_8.id = 8;
4429 heading_9.id = 9;
4430 static_text_10.id = 10;
4431 inline_box_11.id = 11;
4432 static_text_12.id = 12;
4433 inline_box_13.id = 13;
4434 generic_container_14.id = 14;
4435 generic_container_15.id = 15;
4436 heading_16.id = 16;
4437 static_text_17.id = 17;
4438 inline_box_18.id = 18;
4439 generic_container_19.id = 19;
4440 generic_container_20.id = 20;
4441 static_text_21.id = 21;
4442 inline_box_22.id = 22;
4443 heading_23.id = 23;
4444 static_text_24.id = 24;
4445 inline_box_25.id = 25;
4446
4448 root_1.child_ids = {generic_container_2.id, generic_container_8.id,
4449 generic_container_15.id, generic_container_19.id};
4450
4451 generic_container_2.role = ax::mojom::Role::kGenericContainer;
4452 generic_container_2.child_ids = {button_3.id};
4453
4454 button_3.role = ax::mojom::Role::kButton;
4455 button_3.child_ids = {static_text_4.id, svg_root_6.id};
4456
4457 static_text_4.role = ax::mojom::Role::kStaticText;
4458 static_text_4.child_ids = {inline_box_5.id};
4459 static_text_4.SetName("Button");
4460
4462 inline_box_5.SetName("Button");
4463
4464 svg_root_6.role = ax::mojom::Role::kSvgRoot;
4465 svg_root_6.child_ids = {generic_container_7.id};
4467
4468 generic_container_7.role = ax::mojom::Role::kGenericContainer;
4469 generic_container_7.AddState(ax::mojom::State::kIgnored);
4470
4471 generic_container_8.role = ax::mojom::Role::kGenericContainer;
4472 generic_container_8.child_ids = {heading_9.id, static_text_12.id,
4473 generic_container_14.id};
4474
4475 heading_9.role = ax::mojom::Role::kHeading;
4476 heading_9.child_ids = {static_text_10.id};
4477
4478 static_text_10.role = ax::mojom::Role::kStaticText;
4479 static_text_10.child_ids = {inline_box_11.id};
4480 static_text_10.SetName("Heading");
4481
4482 inline_box_11.role = ax::mojom::Role::kInlineTextBox;
4483 inline_box_11.SetName("Heading");
4484
4485 static_text_12.role = ax::mojom::Role::kStaticText;
4486 static_text_12.child_ids = {inline_box_13.id};
4487 static_text_12.SetName("3.14");
4488
4489 inline_box_13.role = ax::mojom::Role::kInlineTextBox;
4490 inline_box_13.SetName("3.14");
4491
4492 generic_container_14.role = ax::mojom::Role::kGenericContainer;
4493 generic_container_14.AddState(ax::mojom::State::kIgnored);
4494
4495 generic_container_15.role = ax::mojom::Role::kGenericContainer;
4496 generic_container_15.child_ids = {heading_16.id};
4497
4498 heading_16.role = ax::mojom::Role::kHeading;
4499 heading_16.child_ids = {static_text_17.id};
4500
4501 static_text_17.role = ax::mojom::Role::kStaticText;
4502 static_text_17.child_ids = {inline_box_18.id};
4503 static_text_17.SetName("Heading");
4504
4505 inline_box_18.role = ax::mojom::Role::kInlineTextBox;
4506 inline_box_18.SetName("Heading");
4507
4508 generic_container_19.role = ax::mojom::Role::kGenericContainer;
4509 generic_container_19.child_ids = {generic_container_20.id, static_text_21.id,
4510 heading_23.id};
4511
4512 generic_container_20.role = ax::mojom::Role::kGenericContainer;
4513 generic_container_20.AddState(ax::mojom::State::kIgnored);
4514
4515 static_text_21.role = ax::mojom::Role::kStaticText;
4516 static_text_21.child_ids = {inline_box_22.id};
4517 static_text_21.SetName("3.14");
4518
4519 inline_box_22.role = ax::mojom::Role::kInlineTextBox;
4520 inline_box_22.SetName("3.14");
4521
4522 heading_23.role = ax::mojom::Role::kHeading;
4523 heading_23.child_ids = {static_text_24.id};
4524
4525 static_text_24.role = ax::mojom::Role::kStaticText;
4526 static_text_24.child_ids = {inline_box_25.id};
4527 static_text_24.SetName("Heading");
4528
4529 inline_box_25.role = ax::mojom::Role::kInlineTextBox;
4530 inline_box_25.SetName("Heading");
4531
4532 SetTree(CreateAXTree({root_1,
4533 generic_container_2,
4534 button_3,
4535 static_text_4,
4536 inline_box_5,
4537 svg_root_6,
4538 generic_container_7,
4539 generic_container_8,
4540 heading_9,
4541 static_text_10,
4542 inline_box_11,
4543 static_text_12,
4544 inline_box_13,
4545 generic_container_14,
4546 generic_container_15,
4547 heading_16,
4548 static_text_17,
4549 inline_box_18,
4550 generic_container_19,
4551 generic_container_20,
4552 static_text_21,
4553 inline_box_22,
4554 heading_23,
4555 static_text_24,
4556 inline_box_25}));
4557
4558 // There are two major cases to consider for format boundaries with ignored
4559 // nodes:
4560 // Case 1: When the ignored node is directly next to the current position.
4561 // Case 2: When the ignored node is directly next to the next/previous format
4562 // boundary.
4563
4564 // Case 1
4565 // This test case spans nodes 2 to 11, inclusively.
4566 {
4567 // Forward movement
4568 TestPositionType text_position = AXNodePosition::CreateTextPosition(
4569 GetTreeID(), inline_box_5.id, 6 /* text_offset */,
4571 ASSERT_NE(nullptr, text_position);
4572 EXPECT_TRUE(text_position->IsTextPosition());
4573 EXPECT_EQ(inline_box_5.id, text_position->anchor_id());
4574 EXPECT_EQ(6, text_position->text_offset());
4575
4576 text_position = text_position->CreateNextFormatEndPosition(
4577 AXBoundaryBehavior::StopAtLastAnchorBoundary);
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 // Backward movement
4584 text_position = AXNodePosition::CreateTextPosition(
4585 GetTreeID(), inline_box_11.id, 0 /* text_offset */,
4587 ASSERT_NE(nullptr, text_position);
4588 EXPECT_TRUE(text_position->IsTextPosition());
4589 EXPECT_EQ(inline_box_11.id, text_position->anchor_id());
4590 EXPECT_EQ(0, text_position->text_offset());
4591
4592 text_position = text_position->CreatePreviousFormatStartPosition(
4593 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4594 ASSERT_NE(nullptr, text_position);
4595 EXPECT_TRUE(text_position->IsTextPosition());
4596 EXPECT_EQ(inline_box_5.id, text_position->anchor_id());
4597 EXPECT_EQ(0, text_position->text_offset());
4598 }
4599
4600 // Case 2
4601 // This test case spans nodes 8 to 25.
4602 {
4603 // Forward movement
4604 TestPositionType text_position = AXNodePosition::CreateTextPosition(
4605 GetTreeID(), inline_box_11.id, 7 /* text_offset */,
4607 ASSERT_NE(nullptr, text_position);
4608 EXPECT_TRUE(text_position->IsTextPosition());
4609 EXPECT_EQ(inline_box_11.id, text_position->anchor_id());
4610 EXPECT_EQ(7, text_position->text_offset());
4611
4612 text_position = text_position->CreateNextFormatEndPosition(
4613 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4614 ASSERT_NE(nullptr, text_position);
4615 EXPECT_TRUE(text_position->IsTextPosition());
4616 EXPECT_EQ(inline_box_13.id, text_position->anchor_id());
4617 EXPECT_EQ(4, text_position->text_offset());
4618
4619 // Backward movement
4620 text_position = AXNodePosition::CreateTextPosition(
4621 GetTreeID(), inline_box_25.id, 0 /* text_offset */,
4623 ASSERT_NE(nullptr, text_position);
4624 EXPECT_TRUE(text_position->IsTextPosition());
4625 EXPECT_EQ(inline_box_25.id, text_position->anchor_id());
4626 EXPECT_EQ(0, text_position->text_offset());
4627
4628 text_position = text_position->CreatePreviousFormatStartPosition(
4629 AXBoundaryBehavior::StopAtLastAnchorBoundary);
4630 ASSERT_NE(nullptr, text_position);
4631 EXPECT_TRUE(text_position->IsTextPosition());
4632 EXPECT_EQ(inline_box_22.id, text_position->anchor_id());
4633 EXPECT_EQ(0, text_position->text_offset());
4634 }
4635}

References ui::AXNodeData::AddState(), ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXNodeData::id, ax::mojom::kButton, ax::mojom::kDownstream, ax::mojom::kGenericContainer, ax::mojom::kHeading, ax::mojom::kIgnored, ax::mojom::kInlineTextBox, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ax::mojom::kSvgRoot, ui::AXNodeData::role, ui::AXNodeData::SetName(), and StopAtLastAnchorBoundary.

◆ TEST_F() [285/325]

ui::TEST_F ( AXPositionTest  ,
OperatorEquals   
)

Definition at line 6654 of file ax_node_position_unittest.cc.

6654 {
6655 TestPositionType null_position1 = AXNodePosition::CreateNullPosition();
6656 ASSERT_NE(nullptr, null_position1);
6657 TestPositionType null_position2 = AXNodePosition::CreateNullPosition();
6658 ASSERT_NE(nullptr, null_position2);
6659 EXPECT_EQ(*null_position1, *null_position2);
6660
6661 // Child indices must match.
6662 TestPositionType button_position1 = AXNodePosition::CreateTreePosition(
6663 GetTreeID(), root_.id, 0 /* child_index */);
6664 ASSERT_NE(nullptr, button_position1);
6665 TestPositionType button_position2 = AXNodePosition::CreateTreePosition(
6666 GetTreeID(), root_.id, 0 /* child_index */);
6667 ASSERT_NE(nullptr, button_position2);
6668 EXPECT_EQ(*button_position1, *button_position2);
6669
6670 // Both child indices are invalid. It should result in equivalent null
6671 // positions.
6672 TestPositionType tree_position1 = AXNodePosition::CreateTreePosition(
6673 GetTreeID(), root_.id, 4 /* child_index */);
6674 ASSERT_NE(nullptr, tree_position1);
6675 TestPositionType tree_position2 = AXNodePosition::CreateTreePosition(
6676 GetTreeID(), root_.id, AXNodePosition::INVALID_INDEX);
6677 ASSERT_NE(nullptr, tree_position2);
6678 EXPECT_EQ(*tree_position1, *tree_position2);
6679
6680 // An invalid position should not be equivalent to an "after children"
6681 // position.
6682 tree_position1 = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
6683 3 /* child_index */);
6684 ASSERT_NE(nullptr, tree_position1);
6685 tree_position2 = AXNodePosition::CreateTreePosition(GetTreeID(), root_.id,
6686 -1 /* child_index */);
6687 ASSERT_NE(nullptr, tree_position2);
6688 EXPECT_NE(*tree_position1, *tree_position2);
6689
6690 // Two "after children" positions on the same node should be equivalent.
6691 tree_position1 = AXNodePosition::CreateTreePosition(
6692 GetTreeID(), text_field_.id, 3 /* child_index */);
6693 ASSERT_NE(nullptr, tree_position1);
6694 tree_position2 = AXNodePosition::CreateTreePosition(
6695 GetTreeID(), text_field_.id, 3 /* child_index */);
6696 ASSERT_NE(nullptr, tree_position2);
6697 EXPECT_EQ(*tree_position1, *tree_position2);
6698
6699 // Two "before text" positions on the same node should be equivalent.
6700 tree_position1 = AXNodePosition::CreateTreePosition(
6701 GetTreeID(), inline_box1_.id, AXNodePosition::BEFORE_TEXT);
6702 ASSERT_NE(nullptr, tree_position1);
6703 tree_position2 = AXNodePosition::CreateTreePosition(
6704 GetTreeID(), inline_box1_.id, AXNodePosition::BEFORE_TEXT);
6705 ASSERT_NE(nullptr, tree_position2);
6706 EXPECT_EQ(*tree_position1, *tree_position2);
6707
6708 // Both text offsets are invalid. It should result in equivalent null
6709 // positions.
6710 TestPositionType text_position1 = AXNodePosition::CreateTextPosition(
6711 GetTreeID(), inline_box1_.id, 15 /* text_offset */,
6713 ASSERT_NE(nullptr, text_position1);
6714 ASSERT_TRUE(text_position1->IsNullPosition());
6715 TestPositionType text_position2 = AXNodePosition::CreateTextPosition(
6716 GetTreeID(), text_field_.id, -1 /* text_offset */,
6718 ASSERT_NE(nullptr, text_position2);
6719 ASSERT_TRUE(text_position2->IsNullPosition());
6720 EXPECT_EQ(*text_position1, *text_position2);
6721
6722 text_position1 = AXNodePosition::CreateTextPosition(
6723 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
6725 ASSERT_NE(nullptr, text_position1);
6726 ASSERT_TRUE(text_position1->IsTextPosition());
6727 text_position2 = AXNodePosition::CreateTextPosition(
6728 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
6730 ASSERT_NE(nullptr, text_position2);
6731 ASSERT_TRUE(text_position2->IsTextPosition());
6732 EXPECT_EQ(*text_position1, *text_position2);
6733
6734 // Affinities should not matter.
6735 text_position2 = AXNodePosition::CreateTextPosition(
6736 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
6738 ASSERT_NE(nullptr, text_position2);
6739 ASSERT_TRUE(text_position2->IsTextPosition());
6740 EXPECT_EQ(*text_position1, *text_position2);
6741
6742 // Text offsets should match.
6743 text_position1 = AXNodePosition::CreateTextPosition(
6744 GetTreeID(), inline_box1_.id, 5 /* text_offset */,
6746 ASSERT_NE(nullptr, text_position1);
6747 ASSERT_TRUE(text_position1->IsTextPosition());
6748 EXPECT_NE(*text_position1, *text_position2);
6749
6750 // Two "after text" positions on the same node should be equivalent.
6751 text_position1 = AXNodePosition::CreateTextPosition(
6752 GetTreeID(), line_break_.id, 1 /* text_offset */,
6754 ASSERT_NE(nullptr, text_position1);
6755 ASSERT_TRUE(text_position1->IsTextPosition());
6756 text_position2 = AXNodePosition::CreateTextPosition(
6757 GetTreeID(), line_break_.id, 1 /* text_offset */,
6759 ASSERT_NE(nullptr, text_position2);
6760 ASSERT_TRUE(text_position2->IsTextPosition());
6761 EXPECT_EQ(*text_position1, *text_position2);
6762
6763 // Two text positions that are consecutive, one "before text" and one "after
6764 // text".
6765 text_position1 = AXNodePosition::CreateTextPosition(
6766 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
6768 ASSERT_NE(nullptr, text_position1);
6769 ASSERT_TRUE(text_position1->IsTextPosition());
6770 text_position2 = AXNodePosition::CreateTextPosition(
6771 GetTreeID(), line_break_.id, 1 /* text_offset */,
6773 ASSERT_NE(nullptr, text_position2);
6774 ASSERT_TRUE(text_position2->IsTextPosition());
6775 EXPECT_EQ(*text_position1, *text_position2);
6776
6777 // Two "after text" positions on a parent and child should be equivalent, in
6778 // the middle of the document...
6779 text_position1 = AXNodePosition::CreateTextPosition(
6780 GetTreeID(), static_text1_.id, 6 /* text_offset */,
6782 ASSERT_NE(nullptr, text_position1);
6783 ASSERT_TRUE(text_position1->IsTextPosition());
6784 text_position2 = AXNodePosition::CreateTextPosition(
6785 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
6787 ASSERT_NE(nullptr, text_position2);
6788 ASSERT_TRUE(text_position2->IsTextPosition());
6789 EXPECT_EQ(*text_position1, *text_position2);
6790
6791 // ...and at the end of the document.
6792 text_position1 = AXNodePosition::CreateTextPosition(
6793 GetTreeID(), static_text2_.id, 6 /* text_offset */,
6795 ASSERT_NE(nullptr, text_position1);
6796 ASSERT_TRUE(text_position1->IsTextPosition());
6797 text_position2 = AXNodePosition::CreateTextPosition(
6798 GetTreeID(), inline_box2_.id, 6 /* text_offset */,
6800 ASSERT_NE(nullptr, text_position2);
6801 ASSERT_TRUE(text_position2->IsTextPosition());
6802 // Validate that we're actually at the end of the document by normalizing to
6803 // the equivalent "before character" position.
6804 EXPECT_TRUE(
6805 text_position1->AsLeafTextPositionBeforeCharacter()->IsNullPosition());
6806 EXPECT_TRUE(
6807 text_position2->AsLeafTextPositionBeforeCharacter()->IsNullPosition());
6808 // Now compare the positions.
6809 EXPECT_EQ(*text_position1, *text_position2);
6810}

References ui::AXPosition< AXNodePosition, AXNode >::BEFORE_TEXT, ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), ui::AXPosition< AXNodePosition, AXNode >::INVALID_INDEX, ax::mojom::kDownstream, and ax::mojom::kUpstream.

◆ TEST_F() [286/325]

ui::TEST_F ( AXPositionTest  ,
OperatorEqualsSameTextOffsetDifferentAnchorIdLeaf   
)

Definition at line 6846 of file ax_node_position_unittest.cc.

6846 {
6847 TestPositionType text_position_one = AXNodePosition::CreateTextPosition(
6848 GetTreeID(), button_.id, 0 /* text_offset */,
6850 ASSERT_NE(nullptr, text_position_one);
6851 ASSERT_TRUE(text_position_one->IsTextPosition());
6852
6853 TestPositionType text_position_two = AXNodePosition::CreateTextPosition(
6854 GetTreeID(), check_box_.id, 0 /* text_offset */,
6856 ASSERT_NE(nullptr, text_position_two);
6857 ASSERT_TRUE(text_position_two->IsTextPosition());
6858
6859 ASSERT_TRUE(*text_position_one == *text_position_two);
6860 ASSERT_TRUE(*text_position_two == *text_position_one);
6861}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kDownstream.

◆ TEST_F() [287/325]

ui::TEST_F ( AXPositionTest  ,
OperatorEqualsSameTextOffsetDifferentAnchorIdRoot   
)

Definition at line 6829 of file ax_node_position_unittest.cc.

6829 {
6830 TestPositionType text_position_one = AXNodePosition::CreateTextPosition(
6831 GetTreeID(), root_.id, 0 /* text_offset */,
6833 ASSERT_NE(nullptr, text_position_one);
6834 ASSERT_TRUE(text_position_one->IsTextPosition());
6835
6836 TestPositionType text_position_two = AXNodePosition::CreateTextPosition(
6837 GetTreeID(), check_box_.id, 0 /* text_offset */,
6839 ASSERT_NE(nullptr, text_position_two);
6840 ASSERT_TRUE(text_position_two->IsTextPosition());
6841
6842 ASSERT_TRUE(*text_position_one == *text_position_two);
6843 ASSERT_TRUE(*text_position_two == *text_position_one);
6844}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kDownstream.

◆ TEST_F() [288/325]

ui::TEST_F ( AXPositionTest  ,
OperatorEqualsSameTextOffsetSameAnchorId   
)

Definition at line 6812 of file ax_node_position_unittest.cc.

6812 {
6813 TestPositionType text_position_one = AXNodePosition::CreateTextPosition(
6814 GetTreeID(), root_.id, 0 /* text_offset */,
6816 ASSERT_NE(nullptr, text_position_one);
6817 ASSERT_TRUE(text_position_one->IsTextPosition());
6818
6819 TestPositionType text_position_two = AXNodePosition::CreateTextPosition(
6820 GetTreeID(), root_.id, 0 /* text_offset */,
6822 ASSERT_NE(nullptr, text_position_two);
6823 ASSERT_TRUE(text_position_two->IsTextPosition());
6824
6825 ASSERT_TRUE(*text_position_one == *text_position_two);
6826 ASSERT_TRUE(*text_position_two == *text_position_one);
6827}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kDownstream.

◆ TEST_F() [289/325]

ui::TEST_F ( AXPositionTest  ,
OperatorsLessThanAndGreaterThan   
)

Definition at line 6863 of file ax_node_position_unittest.cc.

6863 {
6864 TestPositionType null_position1 = AXNodePosition::CreateNullPosition();
6865 ASSERT_NE(nullptr, null_position1);
6866 TestPositionType null_position2 = AXNodePosition::CreateNullPosition();
6867 ASSERT_NE(nullptr, null_position2);
6868 EXPECT_FALSE(*null_position1 < *null_position2);
6869 EXPECT_FALSE(*null_position1 > *null_position2);
6870
6871 TestPositionType button_position1 = AXNodePosition::CreateTreePosition(
6872 GetTreeID(), root_.id, 0 /* child_index */);
6873 ASSERT_NE(nullptr, button_position1);
6874 TestPositionType button_position2 = AXNodePosition::CreateTreePosition(
6875 GetTreeID(), root_.id, 1 /* child_index */);
6876 ASSERT_NE(nullptr, button_position2);
6877 EXPECT_LT(*button_position1, *button_position2);
6878 EXPECT_GT(*button_position2, *button_position1);
6879
6880 TestPositionType tree_position1 = AXNodePosition::CreateTreePosition(
6881 GetTreeID(), text_field_.id, 2 /* child_index */);
6882 ASSERT_NE(nullptr, tree_position1);
6883 // An "after children" position.
6884 TestPositionType tree_position2 = AXNodePosition::CreateTreePosition(
6885 GetTreeID(), text_field_.id, 3 /* child_index */);
6886 ASSERT_NE(nullptr, tree_position2);
6887 EXPECT_LT(*tree_position1, *tree_position2);
6888 EXPECT_GT(*tree_position2, *tree_position1);
6889
6890 // A "before text" position.
6891 tree_position1 = AXNodePosition::CreateTreePosition(
6892 GetTreeID(), inline_box1_.id, AXNodePosition::BEFORE_TEXT);
6893 ASSERT_NE(nullptr, tree_position1);
6894 // An "after text" position.
6895 tree_position2 = AXNodePosition::CreateTreePosition(
6896 GetTreeID(), inline_box1_.id, 0 /* child_index */);
6897 ASSERT_NE(nullptr, tree_position2);
6898 EXPECT_LT(*tree_position1, *tree_position2);
6899 EXPECT_GT(*tree_position2, *tree_position1);
6900
6901 // Two text positions that share a common anchor.
6902 TestPositionType text_position1 = AXNodePosition::CreateTextPosition(
6903 GetTreeID(), inline_box1_.id, 2 /* text_offset */,
6905 ASSERT_NE(nullptr, text_position1);
6906 ASSERT_TRUE(text_position1->IsTextPosition());
6907 TestPositionType text_position2 = AXNodePosition::CreateTextPosition(
6908 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
6910 ASSERT_NE(nullptr, text_position2);
6911 ASSERT_TRUE(text_position2->IsTextPosition());
6912 EXPECT_GT(*text_position1, *text_position2);
6913 EXPECT_LT(*text_position2, *text_position1);
6914
6915 // Affinities should not matter.
6916 text_position2 = AXNodePosition::CreateTextPosition(
6917 GetTreeID(), inline_box1_.id, 0 /* 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 // An "after text" position.
6925 text_position1 = AXNodePosition::CreateTextPosition(
6926 GetTreeID(), line_break_.id, 1 /* text_offset */,
6928 ASSERT_NE(nullptr, text_position1);
6929 ASSERT_TRUE(text_position1->IsTextPosition());
6930 // A "before text" position.
6931 text_position2 = AXNodePosition::CreateTextPosition(
6932 GetTreeID(), line_break_.id, 0 /* text_offset */,
6934 ASSERT_NE(nullptr, text_position2);
6935 ASSERT_TRUE(text_position2->IsTextPosition());
6936 EXPECT_GT(*text_position1, *text_position2);
6937 EXPECT_LT(*text_position2, *text_position1);
6938
6939 // A text position that is an ancestor of another.
6940 text_position1 = AXNodePosition::CreateTextPosition(
6941 GetTreeID(), text_field_.id, 6 /* text_offset */,
6943 ASSERT_NE(nullptr, text_position1);
6944 ASSERT_TRUE(text_position1->IsTextPosition());
6945 text_position2 = AXNodePosition::CreateTextPosition(
6946 GetTreeID(), inline_box1_.id, 5 /* text_offset */,
6948 ASSERT_NE(nullptr, text_position2);
6949 ASSERT_TRUE(text_position2->IsTextPosition());
6950 EXPECT_GT(*text_position1, *text_position2);
6951 EXPECT_LT(*text_position2, *text_position1);
6952
6953 // Two text positions that share a common ancestor.
6954 text_position1 = AXNodePosition::CreateTextPosition(
6955 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
6957 ASSERT_NE(nullptr, text_position1);
6958 ASSERT_TRUE(text_position1->IsTextPosition());
6959 text_position2 = AXNodePosition::CreateTextPosition(
6960 GetTreeID(), line_break_.id, 0 /* text_offset */,
6962 ASSERT_NE(nullptr, text_position2);
6963 ASSERT_TRUE(text_position2->IsTextPosition());
6964 EXPECT_GT(*text_position1, *text_position2);
6965 EXPECT_LT(*text_position2, *text_position1);
6966
6967 // Two consecutive positions. One "before text" and one "after text".
6968 text_position2 = AXNodePosition::CreateTextPosition(
6969 GetTreeID(), line_break_.id, 1 /* text_offset */,
6971 ASSERT_NE(nullptr, text_position2);
6972 ASSERT_TRUE(text_position2->IsTextPosition());
6973 EXPECT_EQ(*text_position1, *text_position2);
6974
6975 // A text position at the end of the document versus one that isn't.
6976 text_position1 = AXNodePosition::CreateTextPosition(
6977 GetTreeID(), inline_box2_.id, 6 /* text_offset */,
6979 ASSERT_NE(nullptr, text_position1);
6980 ASSERT_TRUE(text_position1->IsTextPosition());
6981 // Validate that we're actually at the end of the document by normalizing to
6982 // the equivalent "before character" position.
6983 EXPECT_TRUE(
6984 text_position1->AsLeafTextPositionBeforeCharacter()->IsNullPosition());
6985 // Now create the not-at-end-of-document position and compare.
6986 text_position2 = AXNodePosition::CreateTextPosition(
6987 GetTreeID(), static_text2_.id, 0 /* text_offset */,
6989 ASSERT_NE(nullptr, text_position2);
6990 ASSERT_TRUE(text_position2->IsTextPosition());
6991 EXPECT_GT(*text_position1, *text_position2);
6992 EXPECT_LT(*text_position2, *text_position1);
6993}

References ui::AXPosition< AXNodePosition, AXNode >::BEFORE_TEXT, ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), ax::mojom::kDownstream, and ax::mojom::kUpstream.

◆ TEST_F() [290/325]

ui::TEST_F ( AXPositionTest  ,
ParagraphEdgesWithPreservedNewLine   
)

Definition at line 1845 of file ax_node_position_unittest.cc.

1845 {
1846 // This test ensures that "At{Start|End}OfParagraph" work correctly when a
1847 // text position is on a preserved newline character.
1848 //
1849 // Newline characters are used to separate paragraphs. If there is a series of
1850 // newline characters, a paragraph should start after the last newline
1851 // character.
1852 // ++1 kRootWebArea isLineBreakingObject
1853 // ++++2 kStaticText "some text"
1854 // ++++++3 kInlineTextBox "some text"
1855 // ++++4 kGenericContainer isLineBreakingObject
1856 // ++++++5 kStaticText "\nmore text"
1857 // ++++++++6 kInlineTextBox "\n" isLineBreakingObject
1858 // ++++++++7 kInlineTextBox "more text"
1859
1860 AXNodeData root_data;
1861 root_data.id = 1;
1864 true);
1865
1866 AXNodeData static_text_data_1;
1867 static_text_data_1.id = 2;
1868 static_text_data_1.role = ax::mojom::Role::kStaticText;
1869 static_text_data_1.SetName("some text");
1870
1871 AXNodeData some_text_data;
1872 some_text_data.id = 3;
1873 some_text_data.role = ax::mojom::Role::kInlineTextBox;
1874 some_text_data.SetName("some text");
1875
1876 AXNodeData container_data;
1877 container_data.id = 4;
1879 container_data.AddBoolAttribute(
1881
1882 AXNodeData static_text_data_2;
1883 static_text_data_2.id = 5;
1884 static_text_data_2.role = ax::mojom::Role::kStaticText;
1885 static_text_data_2.SetName("\nmore text");
1886
1887 AXNodeData preserved_newline_data;
1888 preserved_newline_data.id = 6;
1889 preserved_newline_data.role = ax::mojom::Role::kInlineTextBox;
1890 preserved_newline_data.SetName("\n");
1891 preserved_newline_data.AddBoolAttribute(
1893
1894 AXNodeData more_text_data;
1895 more_text_data.id = 7;
1896 more_text_data.role = ax::mojom::Role::kInlineTextBox;
1897 more_text_data.SetName("more text");
1898
1899 static_text_data_1.child_ids = {some_text_data.id};
1900 container_data.child_ids = {static_text_data_2.id};
1901 static_text_data_2.child_ids = {preserved_newline_data.id, more_text_data.id};
1902 root_data.child_ids = {static_text_data_1.id, container_data.id};
1903
1904 SetTree(CreateAXTree({root_data, static_text_data_1, some_text_data,
1905 container_data, static_text_data_2,
1906 preserved_newline_data, more_text_data}));
1907
1908 // Text position "some tex<t>\nmore text".
1909 TestPositionType text_position1 = AXNodePosition::CreateTextPosition(
1910 GetTreeID(), root_data.id, 8 /* text_offset */,
1912 EXPECT_FALSE(text_position1->AtEndOfParagraph());
1913 EXPECT_FALSE(text_position1->AtStartOfParagraph());
1914
1915 // Text position "some text<\n>more text".
1916 TestPositionType text_position2 = AXNodePosition::CreateTextPosition(
1917 GetTreeID(), root_data.id, 9 /* text_offset */,
1919 EXPECT_FALSE(text_position2->AtEndOfParagraph());
1920 EXPECT_FALSE(text_position2->AtStartOfParagraph());
1921
1922 // Text position "some text<\n>more text".
1923 TestPositionType text_position3 = AXNodePosition::CreateTextPosition(
1924 GetTreeID(), root_data.id, 9 /* text_offset */,
1926 EXPECT_FALSE(text_position3->AtEndOfParagraph());
1927 EXPECT_FALSE(text_position3->AtStartOfParagraph());
1928
1929 // Text position "some text\n<m>ore text".
1930 TestPositionType text_position4 = AXNodePosition::CreateTextPosition(
1931 GetTreeID(), root_data.id, 10 /* text_offset */,
1933 EXPECT_FALSE(text_position4->AtEndOfParagraph());
1934 EXPECT_TRUE(text_position4->AtStartOfParagraph());
1935
1936 // Text position "some text\n<m>ore text".
1937 TestPositionType text_position5 = AXNodePosition::CreateTextPosition(
1938 GetTreeID(), root_data.id, 10 /* text_offset */,
1940 EXPECT_TRUE(text_position5->AtEndOfParagraph());
1941 EXPECT_FALSE(text_position5->AtStartOfParagraph());
1942
1943 // Text position "<\n>more text".
1944 TestPositionType text_position6 = AXNodePosition::CreateTextPosition(
1945 GetTreeID(), container_data.id, 0 /* text_offset */,
1947 EXPECT_FALSE(text_position6->AtEndOfParagraph());
1948 EXPECT_FALSE(text_position6->AtStartOfParagraph());
1949
1950 // Text position "\n<m>ore text".
1951 TestPositionType text_position7 = AXNodePosition::CreateTextPosition(
1952 GetTreeID(), container_data.id, 1 /* text_offset */,
1954 EXPECT_FALSE(text_position7->AtEndOfParagraph());
1955 EXPECT_TRUE(text_position7->AtStartOfParagraph());
1956
1957 // Text position "\n<m>ore text".
1958 TestPositionType text_position8 = AXNodePosition::CreateTextPosition(
1959 GetTreeID(), container_data.id, 1 /* text_offset */,
1961 EXPECT_TRUE(text_position8->AtEndOfParagraph());
1962 EXPECT_FALSE(text_position8->AtStartOfParagraph());
1963
1964 // Text position "\n<m>ore text".
1965 TestPositionType text_position9 = AXNodePosition::CreateTextPosition(
1966 GetTreeID(), static_text_data_2.id, 1 /* text_offset */,
1968 EXPECT_FALSE(text_position9->AtEndOfParagraph());
1969 EXPECT_TRUE(text_position9->AtStartOfParagraph());
1970
1971 // Text position "\n<m>ore text".
1972 TestPositionType text_position10 = AXNodePosition::CreateTextPosition(
1973 GetTreeID(), static_text_data_2.id, 1 /* text_offset */,
1975 EXPECT_TRUE(text_position10->AtEndOfParagraph());
1976 EXPECT_FALSE(text_position10->AtStartOfParagraph());
1977
1978 TestPositionType text_position11 = AXNodePosition::CreateTextPosition(
1979 GetTreeID(), preserved_newline_data.id, 0 /* text_offset */,
1981 EXPECT_FALSE(text_position11->AtEndOfParagraph());
1982 EXPECT_FALSE(text_position11->AtStartOfParagraph());
1983
1984 TestPositionType text_position12 = AXNodePosition::CreateTextPosition(
1985 GetTreeID(), preserved_newline_data.id, 1 /* text_offset */,
1987 EXPECT_TRUE(text_position12->AtEndOfParagraph());
1988 EXPECT_FALSE(text_position12->AtStartOfParagraph());
1989
1990 TestPositionType text_position13 = AXNodePosition::CreateTextPosition(
1991 GetTreeID(), more_text_data.id, 0 /* text_offset */,
1993 EXPECT_FALSE(text_position13->AtEndOfParagraph());
1994 EXPECT_TRUE(text_position13->AtStartOfParagraph());
1995
1996 TestPositionType text_position14 = AXNodePosition::CreateTextPosition(
1997 GetTreeID(), more_text_data.id, 1 /* text_offset */,
1999 EXPECT_FALSE(text_position14->AtEndOfParagraph());
2000 EXPECT_FALSE(text_position14->AtStartOfParagraph());
2001}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kGenericContainer, ax::mojom::kInlineTextBox, ax::mojom::kIsLineBreakingObject, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ax::mojom::kUpstream, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ TEST_F() [291/325]

ui::TEST_F ( AXPositionTest  ,
PreviousParagraphEndStopAtAnchorBoundaryWithConsecutiveParentChildLineBreakingObjects   
)

Definition at line 2003 of file ax_node_position_unittest.cc.

2005 {
2006 // This test updates the tree structure to test a specific edge case -
2007 // CreatePreviousParagraphEndPosition(), stopping at an anchor boundary,
2008 // with consecutive parent-child line breaking objects.
2009 // ++1 rootWebArea
2010 // ++++2 staticText name="first"
2011 // ++++3 genericContainer isLineBreakingObject
2012 // ++++++4 genericContainer isLineBreakingObject
2013 // ++++++5 staticText name="second"
2014 AXNodeData root_data;
2015 root_data.id = 1;
2017
2018 AXNodeData static_text_data_a;
2019 static_text_data_a.id = 2;
2020 static_text_data_a.role = ax::mojom::Role::kStaticText;
2021 static_text_data_a.SetName("first");
2022
2023 AXNodeData container_data_a;
2024 container_data_a.id = 3;
2025 container_data_a.role = ax::mojom::Role::kGenericContainer;
2026 container_data_a.AddBoolAttribute(
2028
2029 AXNodeData container_data_b;
2030 container_data_b.id = 4;
2031 container_data_b.role = ax::mojom::Role::kGenericContainer;
2032 container_data_b.AddBoolAttribute(
2034
2035 AXNodeData static_text_data_b;
2036 static_text_data_b.id = 5;
2037 static_text_data_b.role = ax::mojom::Role::kStaticText;
2038 static_text_data_b.SetName("second");
2039
2040 root_data.child_ids = {static_text_data_a.id, container_data_a.id};
2041 container_data_a.child_ids = {container_data_b.id, static_text_data_b.id};
2042
2043 SetTree(CreateAXTree({root_data, static_text_data_a, container_data_a,
2044 container_data_b, static_text_data_b}));
2045
2046 TestPositionType test_position = AXNodePosition::CreateTextPosition(
2047 GetTreeID(), root_data.id, 11 /* text_offset */,
2049
2050 test_position = test_position->CreatePreviousParagraphEndPosition(
2051 AXBoundaryBehavior::StopAtAnchorBoundary);
2052 EXPECT_TRUE(test_position->IsTextPosition());
2053 EXPECT_EQ(root_data.id, test_position->anchor_id());
2054 EXPECT_EQ(5, test_position->text_offset());
2055}

References ui::AXNodeData::AddBoolAttribute(), ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kGenericContainer, ax::mojom::kIsLineBreakingObject, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXNodeData::role, ui::AXNodeData::SetName(), and StopAtAnchorBoundary.

◆ TEST_F() [292/325]

ui::TEST_F ( AXPositionTest  ,
ReciprocalCreateNextAndPreviousCharacterPosition   
)

Definition at line 6589 of file ax_node_position_unittest.cc.

6589 {
6590 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
6591 GetTreeID(), root_.id, 0 /* child_index */);
6592 TestPositionType text_position = tree_position->AsTextPosition();
6593 ASSERT_NE(nullptr, text_position);
6594 ASSERT_TRUE(text_position->IsTextPosition());
6595
6596 size_t next_character_moves = 0;
6597 while (!text_position->IsNullPosition()) {
6598 TestPositionType moved_position =
6599 text_position->CreateNextCharacterPosition(
6600 AXBoundaryBehavior::CrossBoundary);
6601 ASSERT_NE(nullptr, moved_position);
6602
6603 text_position = std::move(moved_position);
6604 ++next_character_moves;
6605 }
6606
6607 tree_position = AXNodePosition::CreateTreePosition(
6608 GetTreeID(), root_.id, root_.child_ids.size() /* child_index */);
6609 text_position = tree_position->AsTextPosition();
6610 ASSERT_NE(nullptr, text_position);
6611 ASSERT_TRUE(text_position->IsTextPosition());
6612
6613 size_t previous_character_moves = 0;
6614 while (!text_position->IsNullPosition()) {
6615 TestPositionType moved_position =
6616 text_position->CreatePreviousCharacterPosition(
6617 AXBoundaryBehavior::CrossBoundary);
6618 ASSERT_NE(nullptr, moved_position);
6619
6620 text_position = std::move(moved_position);
6621 ++previous_character_moves;
6622 }
6623
6624 EXPECT_EQ(next_character_moves, previous_character_moves);
6625 EXPECT_EQ(strlen(TEXT_VALUE), next_character_moves - 1);
6626}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), and CrossBoundary.

◆ TEST_F() [293/325]

ui::TEST_F ( AXPositionTest  ,
Serialize   
)

Definition at line 580 of file ax_node_position_unittest.cc.

580 {
581 TestPositionType null_position = AXNodePosition::CreateNullPosition();
582 ASSERT_NE(nullptr, null_position);
583 TestPositionType copy_position =
584 AXNodePosition::Unserialize(null_position->Serialize());
585 ASSERT_NE(nullptr, copy_position);
586 EXPECT_TRUE(copy_position->IsNullPosition());
587
588 TestPositionType tree_position = AXNodePosition::CreateTreePosition(
589 GetTreeID(), root_.id, 1 /* child_index */);
590 ASSERT_NE(nullptr, tree_position);
591 copy_position = AXNodePosition::Unserialize(tree_position->Serialize());
592 ASSERT_NE(nullptr, copy_position);
593 EXPECT_TRUE(copy_position->IsTreePosition());
594 EXPECT_EQ(root_.id, copy_position->anchor_id());
595 EXPECT_EQ(1, copy_position->child_index());
596 EXPECT_EQ(AXNodePosition::INVALID_OFFSET, copy_position->text_offset());
597
598 tree_position = AXNodePosition::CreateTreePosition(
599 GetTreeID(), root_.id, AXNodePosition::BEFORE_TEXT);
600 ASSERT_NE(nullptr, tree_position);
601 copy_position = AXNodePosition::Unserialize(tree_position->Serialize());
602 ASSERT_NE(nullptr, copy_position);
603 EXPECT_TRUE(copy_position->IsTreePosition());
604 EXPECT_EQ(root_.id, copy_position->anchor_id());
605 EXPECT_EQ(AXNodePosition::BEFORE_TEXT, copy_position->child_index());
606 EXPECT_EQ(AXNodePosition::INVALID_OFFSET, copy_position->text_offset());
607
608 TestPositionType text_position = AXNodePosition::CreateTextPosition(
609 GetTreeID(), text_field_.id, 0 /* text_offset */,
611 ASSERT_NE(nullptr, text_position);
612 ASSERT_TRUE(text_position->IsTextPosition());
613 copy_position = AXNodePosition::Unserialize(text_position->Serialize());
614 ASSERT_NE(nullptr, copy_position);
615 EXPECT_TRUE(copy_position->IsTextPosition());
616 EXPECT_EQ(text_field_.id, copy_position->anchor_id());
617 EXPECT_EQ(0, copy_position->text_offset());
618 EXPECT_EQ(ax::mojom::TextAffinity::kUpstream, copy_position->affinity());
619
620 text_position = AXNodePosition::CreateTextPosition(
621 GetTreeID(), text_field_.id, 0 /* text_offset */,
623 ASSERT_NE(nullptr, text_position);
624 ASSERT_TRUE(text_position->IsTextPosition());
625 copy_position = AXNodePosition::Unserialize(text_position->Serialize());
626 ASSERT_NE(nullptr, copy_position);
627 EXPECT_TRUE(copy_position->IsTextPosition());
628 EXPECT_EQ(text_field_.id, copy_position->anchor_id());
629 EXPECT_EQ(0, copy_position->text_offset());
630 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, copy_position->affinity());
631 EXPECT_EQ(AXNodePosition::INVALID_INDEX, copy_position->child_index());
632}

References ui::AXPosition< AXNodePosition, AXNode >::BEFORE_TEXT, ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), ui::AXPosition< AXNodePosition, AXNode >::INVALID_INDEX, ui::AXPosition< AXNodePosition, AXNode >::INVALID_OFFSET, ax::mojom::kDownstream, ax::mojom::kUpstream, and ui::AXPosition< AXNodePosition, AXNode >::Unserialize().

◆ TEST_F() [294/325]

ui::TEST_F ( AXPositionTest  ,
Swap   
)

Definition at line 6995 of file ax_node_position_unittest.cc.

6995 {
6996 TestPositionType null_position1 = AXNodePosition::CreateNullPosition();
6997 ASSERT_NE(nullptr, null_position1);
6998 TestPositionType null_position2 = AXNodePosition::CreateNullPosition();
6999 ASSERT_NE(nullptr, null_position2);
7000
7001 swap(*null_position1, *null_position2);
7002 EXPECT_TRUE(null_position1->IsNullPosition());
7003 EXPECT_TRUE(null_position2->IsNullPosition());
7004
7005 TestPositionType tree_position1 = AXNodePosition::CreateTreePosition(
7006 GetTreeID(), root_.id, 2 /* child_index */);
7007 ASSERT_NE(nullptr, tree_position1);
7008 TestPositionType tree_position2 = AXNodePosition::CreateTreePosition(
7009 GetTreeID(), text_field_.id, 3 /* child_index */);
7010 ASSERT_NE(nullptr, tree_position2);
7011
7012 swap(*tree_position1, *tree_position2);
7013 EXPECT_TRUE(tree_position1->IsTreePosition());
7014 EXPECT_EQ(GetTreeID(), tree_position1->tree_id());
7015 EXPECT_EQ(text_field_.id, tree_position1->anchor_id());
7016 EXPECT_EQ(3, tree_position1->child_index());
7017 EXPECT_TRUE(tree_position1->IsTreePosition());
7018 EXPECT_EQ(GetTreeID(), tree_position2->tree_id());
7019 EXPECT_EQ(root_.id, tree_position2->anchor_id());
7020 EXPECT_EQ(2, tree_position2->child_index());
7021
7022 swap(*tree_position1, *null_position1);
7023 EXPECT_TRUE(tree_position1->IsNullPosition());
7024 EXPECT_TRUE(null_position1->IsTreePosition());
7025 EXPECT_EQ(GetTreeID(), null_position1->tree_id());
7026 EXPECT_EQ(text_field_.id, null_position1->anchor_id());
7027 EXPECT_EQ(3, null_position1->child_index());
7028
7029 TestPositionType text_position = AXNodePosition::CreateTextPosition(
7030 GetTreeID(), line_break_.id, 1 /* text_offset */,
7032 ASSERT_NE(nullptr, text_position);
7033
7034 swap(*text_position, *null_position1);
7035 EXPECT_TRUE(null_position1->IsTextPosition());
7036 EXPECT_EQ(GetTreeID(), text_position->tree_id());
7037 EXPECT_EQ(line_break_.id, null_position1->anchor_id());
7038 EXPECT_EQ(1, null_position1->text_offset());
7039 EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, null_position1->affinity());
7040 EXPECT_TRUE(text_position->IsTreePosition());
7041 EXPECT_EQ(GetTreeID(), text_position->tree_id());
7042 EXPECT_EQ(text_field_.id, text_position->anchor_id());
7043 EXPECT_EQ(3, text_position->child_index());
7044}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), ax::mojom::kDownstream, and swap().

◆ TEST_F() [295/325]

ui::TEST_F ( AXPositionTest  ,
TextNavigationWithCollapsedCombobox   
)

Definition at line 7828 of file ax_node_position_unittest.cc.

7828 {
7829 // On Windows, a <select> element is replaced by a combobox that contains
7830 // an AXMenuListPopup parent of AXMenuListOptions. When the select dropdown is
7831 // collapsed, the subtree of that combobox needs to be hidden and, when
7832 // expanded, it must be accessible in the tree. This test ensures we can't
7833 // navigate into the options of a collapsed menu list popup.
7834 g_ax_embedded_object_behavior = AXEmbeddedObjectBehavior::kExposeCharacter;
7835
7836 // ++1 kRootWebArea
7837 // ++++2 kStaticText "Hi"
7838 // ++++++3 kInlineTextBox "Hi"
7839 // ++++4 kPopUpButton
7840 // ++++++5 kMenuListPopup
7841 // ++++++++6 kMenuListOption "Option"
7842 // ++++7 kStaticText "3.14"
7843 // ++++++8 kInlineTextBox "3.14"
7844 AXNodeData root_1;
7845 AXNodeData static_text_2;
7846 AXNodeData inline_box_3;
7847 AXNodeData popup_button_4;
7848 AXNodeData menu_list_popup_5;
7849 AXNodeData menu_list_option_6;
7850 AXNodeData static_text_7;
7851 AXNodeData inline_box_8;
7852
7853 root_1.id = 1;
7854 static_text_2.id = 2;
7855 inline_box_3.id = 3;
7856 popup_button_4.id = 4;
7857 menu_list_popup_5.id = 5;
7858 menu_list_option_6.id = 6;
7859 static_text_7.id = 7;
7860 inline_box_8.id = 8;
7861
7863 root_1.child_ids = {static_text_2.id, popup_button_4.id, static_text_7.id};
7864
7865 static_text_2.role = ax::mojom::Role::kStaticText;
7866 static_text_2.SetName("Hi");
7867 static_text_2.child_ids = {inline_box_3.id};
7868
7870 inline_box_3.SetName("Hi");
7872 {0});
7874
7875 popup_button_4.role = ax::mojom::Role::kPopUpButton;
7876 popup_button_4.child_ids = {menu_list_popup_5.id};
7877 popup_button_4.AddState(ax::mojom::State::kCollapsed);
7878
7879 menu_list_popup_5.role = ax::mojom::Role::kMenuListPopup;
7880 menu_list_popup_5.child_ids = {menu_list_option_6.id};
7881
7882 menu_list_option_6.role = ax::mojom::Role::kMenuListOption;
7883 menu_list_option_6.SetName("Option");
7884
7885 static_text_7.role = ax::mojom::Role::kStaticText;
7886 static_text_7.SetName("3.14");
7887 static_text_7.child_ids = {inline_box_8.id};
7888
7890 inline_box_8.SetName("3.14");
7892 {0});
7894
7895 SetTree(CreateAXTree({root_1, static_text_2, inline_box_3, popup_button_4,
7896 menu_list_popup_5, menu_list_option_6, static_text_7,
7897 inline_box_8}));
7898
7899 // Collapsed - Forward navigation.
7900 TestPositionType position = AXNodePosition::CreateTextPosition(
7901 GetTreeID(), inline_box_3.id, 0, ax::mojom::TextAffinity::kDownstream);
7902 ASSERT_NE(nullptr, position);
7903
7904 position = position->CreateNextParagraphStartPosition(
7905 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7906 ASSERT_NE(nullptr, position);
7907 EXPECT_EQ(popup_button_4.id, position->anchor_id());
7908 EXPECT_EQ(0, position->text_offset());
7909
7910 position = position->CreateNextParagraphStartPosition(
7911 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7912 ASSERT_NE(nullptr, position);
7913 EXPECT_EQ(inline_box_8.id, position->anchor_id());
7914 EXPECT_EQ(0, position->text_offset());
7915
7916 // Collapsed - Backward navigation.
7917 position = AXNodePosition::CreateTextPosition(
7918 GetTreeID(), inline_box_8.id, 4, ax::mojom::TextAffinity::kDownstream);
7919 ASSERT_NE(nullptr, position);
7920
7921 position = position->CreatePreviousParagraphEndPosition(
7922 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7923 ASSERT_NE(nullptr, position);
7924 EXPECT_EQ(popup_button_4.id, position->anchor_id());
7925 // The content of this popup button should be replaced with the empty object
7926 // character of length 1.
7927 EXPECT_EQ(1, position->text_offset());
7928
7929 position = position->CreatePreviousParagraphEndPosition(
7930 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7931 ASSERT_NE(nullptr, position);
7932 EXPECT_EQ(inline_box_3.id, position->anchor_id());
7933 EXPECT_EQ(2, position->text_offset());
7934
7935 // Expand the combobox for the rest of the test.
7937 popup_button_4.AddState(ax::mojom::State::kExpanded);
7938 AXTreeUpdate update;
7939 update.nodes = {popup_button_4};
7940 ASSERT_TRUE(GetTree()->Unserialize(update));
7941
7942 // Expanded - Forward navigation.
7943 position = AXNodePosition::CreateTextPosition(
7944 GetTreeID(), inline_box_3.id, 0, ax::mojom::TextAffinity::kDownstream);
7945 ASSERT_NE(nullptr, position);
7946
7947 position = position->CreateNextParagraphStartPosition(
7948 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7949 ASSERT_NE(nullptr, position);
7950 EXPECT_EQ(menu_list_option_6.id, position->anchor_id());
7951 EXPECT_EQ(0, position->text_offset());
7952
7953 position = position->CreateNextParagraphStartPosition(
7954 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7955 ASSERT_NE(nullptr, position);
7956 EXPECT_EQ(inline_box_8.id, position->anchor_id());
7957 EXPECT_EQ(0, position->text_offset());
7958
7959 // Expanded- Backward navigation.
7960 position = AXNodePosition::CreateTextPosition(
7961 GetTreeID(), inline_box_8.id, 4, ax::mojom::TextAffinity::kDownstream);
7962 ASSERT_NE(nullptr, position);
7963
7964 position = position->CreatePreviousParagraphEndPosition(
7965 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7966 ASSERT_NE(nullptr, position);
7967 EXPECT_EQ(menu_list_option_6.id, position->anchor_id());
7968 EXPECT_EQ(1, position->text_offset());
7969
7970 position = position->CreatePreviousParagraphEndPosition(
7971 AXBoundaryBehavior::StopAtLastAnchorBoundary);
7972 ASSERT_NE(nullptr, position);
7973 EXPECT_EQ(inline_box_3.id, position->anchor_id());
7974 EXPECT_EQ(2, position->text_offset());
7975}
void RemoveState(ax::mojom::State state)

References ui::AXNodeData::AddIntListAttribute(), ui::AXNodeData::AddState(), ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), g_ax_embedded_object_behavior, ui::AXNodeData::id, ax::mojom::kCollapsed, ax::mojom::kDownstream, ax::mojom::kExpanded, kExposeCharacter, ax::mojom::kInlineTextBox, ax::mojom::kMenuListOption, ax::mojom::kMenuListPopup, ax::mojom::kPopUpButton, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ax::mojom::kWordEnds, ax::mojom::kWordStarts, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::RemoveState(), ui::AXNodeData::role, ui::AXNodeData::SetName(), and StopAtLastAnchorBoundary.

◆ TEST_F() [296/325]

ui::TEST_F ( AXPositionTest  ,
ToString   
)

Definition at line 634 of file ax_node_position_unittest.cc.

634 {
635 AXNodeData root_data;
636 root_data.id = 1;
638
639 AXNodeData static_text_data_1;
640 static_text_data_1.id = 2;
641 static_text_data_1.role = ax::mojom::Role::kStaticText;
642 static_text_data_1.SetName("some text");
643
644 AXNodeData static_text_data_2;
645 static_text_data_2.id = 3;
646 static_text_data_2.role = ax::mojom::Role::kStaticText;
647 static_text_data_2.SetName(u"\xfffc");
648
649 AXNodeData static_text_data_3;
650 static_text_data_3.id = 4;
651 static_text_data_3.role = ax::mojom::Role::kStaticText;
652 static_text_data_3.SetName("more text");
653
654 root_data.child_ids = {static_text_data_1.id, static_text_data_2.id,
655 static_text_data_3.id};
656
657 SetTree(CreateAXTree(
658 {root_data, static_text_data_1, static_text_data_2, static_text_data_3}));
659
660 TestPositionType text_position_1 = AXNodePosition::CreateTextPosition(
661 GetTreeID(), root_data.id, 0 /* text_offset */,
663 ASSERT_TRUE(text_position_1->IsTextPosition());
664 EXPECT_EQ(
665 "TextPosition anchor_id=1 text_offset=0 affinity=downstream "
666 "annotated_text=<s>ome text\xEF\xBF\xBCmore text",
667 text_position_1->ToString());
668
669 TestPositionType text_position_2 = AXNodePosition::CreateTextPosition(
670 GetTreeID(), root_data.id, 5 /* text_offset */,
672 ASSERT_TRUE(text_position_2->IsTextPosition());
673 EXPECT_EQ(
674 "TextPosition anchor_id=1 text_offset=5 affinity=downstream "
675 "annotated_text=some <t>ext\xEF\xBF\xBCmore text",
676 text_position_2->ToString());
677
678 TestPositionType text_position_3 = AXNodePosition::CreateTextPosition(
679 GetTreeID(), root_data.id, 9 /* text_offset */,
681 ASSERT_TRUE(text_position_3->IsTextPosition());
682 EXPECT_EQ(
683 "TextPosition anchor_id=1 text_offset=9 affinity=downstream "
684 "annotated_text=some text<\xEF\xBF\xBC>more text",
685 text_position_3->ToString());
686
687 TestPositionType text_position_4 = AXNodePosition::CreateTextPosition(
688 GetTreeID(), root_data.id, 10 /* text_offset */,
690 ASSERT_TRUE(text_position_4->IsTextPosition());
691 EXPECT_EQ(
692 "TextPosition anchor_id=1 text_offset=10 affinity=downstream "
693 "annotated_text=some text\xEF\xBF\xBC<m>ore text",
694 text_position_4->ToString());
695
696 TestPositionType text_position_5 = AXNodePosition::CreateTextPosition(
697 GetTreeID(), root_data.id, 19 /* text_offset */,
699 ASSERT_TRUE(text_position_5->IsTextPosition());
700 EXPECT_EQ(
701 "TextPosition anchor_id=1 text_offset=19 affinity=downstream "
702 "annotated_text=some text\xEF\xBF\xBCmore text<>",
703 text_position_5->ToString());
704
705 TestPositionType text_position_6 = AXNodePosition::CreateTextPosition(
706 GetTreeID(), static_text_data_2.id, 0 /* text_offset */,
708 ASSERT_TRUE(text_position_6->IsTextPosition());
709 EXPECT_EQ(
710 "TextPosition anchor_id=3 text_offset=0 affinity=downstream "
711 "annotated_text=<\xEF\xBF\xBC>",
712 text_position_6->ToString());
713
714 TestPositionType text_position_7 = AXNodePosition::CreateTextPosition(
715 GetTreeID(), static_text_data_2.id, 1 /* text_offset */,
717 ASSERT_TRUE(text_position_7->IsTextPosition());
718 EXPECT_EQ(
719 "TextPosition anchor_id=3 text_offset=1 affinity=downstream "
720 "annotated_text=\xEF\xBF\xBC<>",
721 text_position_7->ToString());
722
723 TestPositionType text_position_8 = AXNodePosition::CreateTextPosition(
724 GetTreeID(), static_text_data_3.id, 0 /* text_offset */,
726 ASSERT_TRUE(text_position_8->IsTextPosition());
727 EXPECT_EQ(
728 "TextPosition anchor_id=4 text_offset=0 affinity=downstream "
729 "annotated_text=<m>ore text",
730 text_position_8->ToString());
731
732 TestPositionType text_position_9 = AXNodePosition::CreateTextPosition(
733 GetTreeID(), static_text_data_3.id, 5 /* text_offset */,
735 ASSERT_TRUE(text_position_9->IsTextPosition());
736 EXPECT_EQ(
737 "TextPosition anchor_id=4 text_offset=5 affinity=downstream "
738 "annotated_text=more <t>ext",
739 text_position_9->ToString());
740
741 TestPositionType text_position_10 = AXNodePosition::CreateTextPosition(
742 GetTreeID(), static_text_data_3.id, 9 /* text_offset */,
744 ASSERT_TRUE(text_position_10->IsTextPosition());
745 EXPECT_EQ(
746 "TextPosition anchor_id=4 text_offset=9 affinity=downstream "
747 "annotated_text=more text<>",
748 text_position_10->ToString());
749}

References ui::AXNodeData::child_ids, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXNodeData::id, ax::mojom::kDownstream, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXNodeData::role, and ui::AXNodeData::SetName().

◆ 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 */);
377 TestPositionInstance text_position1 = AXNodePosition::CreateTextPosition(
378 GetTreeID(), line_break1_.id, 1 /* text_offset */,
380 TestPositionInstance text_position2 = AXNodePosition::CreateTextPosition(
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
AXRange< AXPosition< AXNodePosition, AXNode > > TestPositionRange

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), and ax::mojom::kDownstream.

◆ 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();
465 TestPositionInstance test_position1 = AXNodePosition::CreateTextPosition(
466 GetTreeID(), button_.id, 3 /* text_offset */,
468 TestPositionInstance test_position2 = AXNodePosition::CreateTextPosition(
469 GetTreeID(), check_box1_.id, 0 /* text_offset */,
471 TestPositionInstance test_position3 = AXNodePosition::CreateTextPosition(
472 GetTreeID(), check_box2_.id, 0 /* text_offset */,
474 TestPositionInstance test_position4 = AXNodePosition::CreateTextPosition(
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}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kDownstream.

◆ 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();
331 TestPositionInstance test_position1 = AXNodePosition::CreateTextPosition(
332 GetTreeID(), button_.id, 0 /* text_offset */,
334 TestPositionInstance test_position2 = AXNodePosition::CreateTextPosition(
335 GetTreeID(), line_break1_.id, 1 /* text_offset */,
337 TestPositionInstance test_position3 = AXNodePosition::CreateTextPosition(
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}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kDownstream.

◆ 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.
1165 TestPositionInstance button = AXNodePosition::CreateTextPosition(
1166 GetTreeID(), button_.id, 0 /* text_offset */,
1168
1169 TestPositionInstance check_box1 = AXNodePosition::CreateTextPosition(
1170 GetTreeID(), check_box1_.id, 0 /* text_offset */,
1172 TestPositionInstance check_box2 = AXNodePosition::CreateTextPosition(
1173 GetTreeID(), check_box2_.id, 0 /* text_offset */,
1175
1176 TestPositionInstance line1_start = AXNodePosition::CreateTextPosition(
1177 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
1179 TestPositionInstance line1_second_char = AXNodePosition::CreateTextPosition(
1180 GetTreeID(), inline_box1_.id, 1 /* text_offset */,
1182 TestPositionInstance line1_middle = AXNodePosition::CreateTextPosition(
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 */,
1189 TestPositionInstance line1_end = AXNodePosition::CreateTextPosition(
1190 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
1192
1193 TestPositionInstance line2_start = AXNodePosition::CreateTextPosition(
1194 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
1196 TestPositionInstance line2_second_char = AXNodePosition::CreateTextPosition(
1197 GetTreeID(), inline_box2_.id, 1 /* text_offset */,
1199 TestPositionInstance line2_middle = AXNodePosition::CreateTextPosition(
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 */,
1206 TestPositionInstance line2_end = AXNodePosition::CreateTextPosition(
1207 GetTreeID(), inline_box2_.id, 6 /* text_offset */,
1209
1210 TestPositionInstance after_line_end = AXNodePosition::CreateTextPosition(
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)};
1218 EXPECT_TRUE(
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)};
1225 EXPECT_TRUE(
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)};
1273 EXPECT_TRUE(
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)};
1312 EXPECT_TRUE(
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}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kDownstream.

◆ 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
1370 TestPositionInstance button = AXNodePosition::CreateTextPosition(
1371 GetTreeID(), button_.id, 0 /* text_offset */,
1373
1374 TestPositionInstance after_line_end = AXNodePosition::CreateTextPosition(
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}

References ui::AXRelativeBounds::bounds, ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ax::mojom::kDownstream, and ui::AXNodeData::relative_bounds.

◆ TEST_F() [302/325]

ui::TEST_F ( AXRangeTest  ,
GetTextAddingNewlineBetweenParagraphs   
)

Definition at line 913 of file ax_range_unittest.cc.

913 {
914 TestPositionInstance button_start = AXNodePosition::CreateTextPosition(
915 GetTreeID(), button_.id, 0 /* text_offset */,
917 TestPositionInstance button_end = AXNodePosition::CreateTextPosition(
918 GetTreeID(), button_.id, 6 /* text_offset */,
920
921 TestPositionInstance line1_start = AXNodePosition::CreateTextPosition(
922 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
924 TestPositionInstance line1_end = AXNodePosition::CreateTextPosition(
925 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
927
928 TestPositionInstance line2_start = AXNodePosition::CreateTextPosition(
929 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
931 TestPositionInstance line2_end = AXNodePosition::CreateTextPosition(
932 GetTreeID(), inline_box2_.id, 6 /* text_offset */,
934
935 TestPositionInstance after_line_start = AXNodePosition::CreateTextPosition(
936 GetTreeID(), inline_box3_.id, 0 /* text_offset */,
938 TestPositionInstance after_line_end = AXNodePosition::CreateTextPosition(
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);
993 TestPositionInstance start = AXNodePosition::CreateTextPosition(
994 GetTreeID(), root_.id, 0 /* text_offset */,
996 TestPositionInstance end = AXNodePosition::CreateTextPosition(
997 GetTreeID(), root_.id, ALL_TEXT.length() /* text_offset */,
999 TestGetTextForRange(std::move(start), std::move(end), all_text, 1);
1000}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), end, kAsInnerText, ax::mojom::kDownstream, and start.

◆ 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
870 start = AXNodePosition::CreateTextPosition(
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
877 start = AXNodePosition::CreateTextPosition(
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
884 start = AXNodePosition::CreateTextPosition(
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
891 start = AXNodePosition::CreateTextPosition(
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
898 TestPositionInstance after_end = AXNodePosition::CreateTextPosition(
899 GetTreeID(), line_break1_.id, 1 /* text_offset */,
901 TestPositionInstance before_start = AXNodePosition::CreateTextPosition(
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}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), ax::mojom::kDownstream, and start.

◆ 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"
1053 AXNodeData root;
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
1145 TestPositionInstance start = AXNodePosition::CreateTextPosition(
1146 GetTreeID(), inline_box1.id, 0 /* text_offset */,
1148 ASSERT_TRUE(start->IsTextPosition());
1149 TestPositionInstance end = AXNodePosition::CreateTextPosition(
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)

References ui::AXNodeData::AddBoolAttribute(), base::ASCIIToUTF16(), ui::AXNodeData::child_ids, ui::AXTreeID::CreateNewAXTreeID(), ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), end, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNodeData::id, kAsInnerText, ax::mojom::kDownstream, ax::mojom::kInlineTextBox, ax::mojom::kIsLineBreakingObject, ax::mojom::kList, ax::mojom::kListItem, ax::mojom::kListMarker, ax::mojom::kRootWebArea, ax::mojom::kStaticText, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXNodeData::SetName(), start, ui::AXTreeData::title, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data, and ui::AXTreeData::tree_id.

◆ TEST_F() [305/325]

ui::TEST_F ( AXRangeTest  ,
GetTextWithMaxCount   
)

Definition at line 1002 of file ax_range_unittest.cc.

1002 {
1003 TestPositionInstance line1_start = AXNodePosition::CreateTextPosition(
1004 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
1006 TestPositionInstance line2_end = AXNodePosition::CreateTextPosition(
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}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), kAsInnerText, and ax::mojom::kDownstream.

◆ 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.
826 TestPositionInstance start = AXNodePosition::CreateTextPosition(
827 GetTreeID(), button_.id, 2 /* text_offset */,
829 ASSERT_TRUE(start->IsTextPosition());
830 TestPositionInstance end = AXNodePosition::CreateTextPosition(
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 */);
844 end = AXNodePosition::CreateTextPosition(
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}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), end, ax::mojom::kDownstream, and start.

◆ 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 */);
705 TestPositionInstance end = AXNodePosition::CreateTextPosition(
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
715 start = AXNodePosition::CreateTextPosition(
716 GetTreeID(), button_.id, 0 /* text_offset */,
718 ASSERT_TRUE(start->IsTextPosition());
719 end = AXNodePosition::CreateTextPosition(
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_
729 start = AXNodePosition::CreateTextPosition(
730 GetTreeID(), text_field_.id, 0 /* text_offset */,
732 end = AXNodePosition::CreateTextPosition(
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_
743 start = AXNodePosition::CreateTextPosition(
744 GetTreeID(), static_text1_.id, 0 /* text_offset */,
746 ASSERT_TRUE(start->IsTextPosition());
747 end = AXNodePosition::CreateTextPosition(
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_
758 start = AXNodePosition::CreateTextPosition(
759 GetTreeID(), static_text2_.id, 0 /* text_offset */,
761 ASSERT_TRUE(start->IsTextPosition());
762 end = AXNodePosition::CreateTextPosition(
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);
775 start = AXNodePosition::CreateTextPosition(
776 GetTreeID(), static_text1_.id, 0 /* text_offset */,
778 ASSERT_TRUE(start->IsTextPosition());
779 end = AXNodePosition::CreateTextPosition(
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 */);
796 end = AXNodePosition::CreateTextPosition(
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}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), end, ax::mojom::kDownstream, and start.

◆ 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
412 TestPositionInstance text_position1 = AXNodePosition::CreateTextPosition(
413 GetTreeID(), static_text1_.id, 0 /* text_offset */,
415 TestPositionInstance text_position2 = AXNodePosition::CreateTextPosition(
416 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
418 TestPositionInstance text_position3 = AXNodePosition::CreateTextPosition(
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}

References ui::AXPosition< AXNodePosition, AXNode >::CreateNullPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), and ax::mojom::kDownstream.

◆ TEST_F() [309/325]

ui::TEST_F ( AXRangeTest  ,
LeafTextRangeIteration   
)

Definition at line 527 of file ax_range_unittest.cc.

527 {
528 TestPositionInstance button_start = AXNodePosition::CreateTextPosition(
529 GetTreeID(), button_.id, 0 /* text_offset */,
531 TestPositionInstance button_middle = AXNodePosition::CreateTextPosition(
532 GetTreeID(), button_.id, 3 /* text_offset */,
534 TestPositionInstance button_end = AXNodePosition::CreateTextPosition(
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.
540 TestPositionInstance check_box1 = AXNodePosition::CreateTextPosition(
541 GetTreeID(), check_box1_.id, 0 /* text_offset */,
543 TestPositionInstance check_box2 = AXNodePosition::CreateTextPosition(
544 GetTreeID(), check_box2_.id, 0 /* text_offset */,
546
547 TestPositionInstance line1_start = AXNodePosition::CreateTextPosition(
548 GetTreeID(), inline_box1_.id, 0 /* text_offset */,
550 TestPositionInstance line1_middle = AXNodePosition::CreateTextPosition(
551 GetTreeID(), inline_box1_.id, 3 /* text_offset */,
553 TestPositionInstance line1_end = AXNodePosition::CreateTextPosition(
554 GetTreeID(), inline_box1_.id, 6 /* text_offset */,
556
557 TestPositionInstance line_break1_start = AXNodePosition::CreateTextPosition(
558 GetTreeID(), line_break1_.id, 0 /* text_offset */,
560 TestPositionInstance line_break1_end = AXNodePosition::CreateTextPosition(
561 GetTreeID(), line_break1_.id, 1 /* text_offset */,
563
564 TestPositionInstance line2_start = AXNodePosition::CreateTextPosition(
565 GetTreeID(), inline_box2_.id, 0 /* text_offset */,
567 TestPositionInstance line2_middle = AXNodePosition::CreateTextPosition(
568 GetTreeID(), inline_box2_.id, 3 /* text_offset */,
570 TestPositionInstance line2_end = AXNodePosition::CreateTextPosition(
571 GetTreeID(), inline_box2_.id, 6 /* text_offset */,
573
574 TestPositionInstance line_break2_start = AXNodePosition::CreateTextPosition(
575 GetTreeID(), line_break2_.id, 0 /* text_offset */,
577 TestPositionInstance line_break2_end = AXNodePosition::CreateTextPosition(
578 GetTreeID(), line_break2_.id, 1 /* text_offset */,
580
581 TestPositionInstance after_line_start = AXNodePosition::CreateTextPosition(
582 GetTreeID(), inline_box3_.id, 0 /* text_offset */,
584 TestPositionInstance after_line_end = AXNodePosition::CreateTextPosition(
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 */);
675 TestPositionInstance range_end = AXNodePosition::CreateTextPosition(
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}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), ui::AXPosition< AXNodePosition, AXNode >::CreateTreePosition(), i, and ax::mojom::kDownstream.

◆ 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}

References ui::AXTree::GetFromId(), ui::AXNode::GetTableAriaColCount(), ui::AXNode::GetTableAriaRowCount(), ui::AXNode::GetTableCellAriaColIndex(), ui::AXNode::GetTableCellAriaRowIndex(), ui::AXNode::GetTableRowNodeIds(), ax::mojom::kAriaCellColumnIndex, ax::mojom::kAriaCellRowIndex, ax::mojom::kAriaColumnCount, ax::mojom::kAriaRowCount, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTree::root(), and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References ui::AXTableInfo::col_count, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTree::root(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTableInfo::row_count, and ui::AXTableInfo::row_nodes.

◆ 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}

References ui::AXTree::GetFromId(), ui::AXNode::GetTableCellColIndex(), ui::AXNode::GetTableCellRowIndex(), ui::AXNode::GetTableColCount(), ui::AXNode::GetTableRowCount(), ui::AXNode::GetTableRowNodeIds(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTree::root(), and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References ui::AXTree::GetFromId(), ui::AXNode::GetTableCellColIndex(), ui::AXNode::GetTableCellRowIndex(), ui::AXNode::GetTableColCount(), ui::AXNode::GetTableRowCount(), ui::AXNode::GetTableRowNodeIds(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTree::root(), and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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}

References ui::AXTableInfo::cell_id_to_index, ui::AXTableInfo::cell_ids, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTree::root(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTableInfo::row_nodes, and ui::AXTableInfo::unique_cell_ids.

◆ 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}

References ui::AXTableInfo::col_count, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTree::root(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTableInfo::row_count, and ui::AXTableInfo::row_nodes.

◆ 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}

References ui::AXNode::children(), ui::AXTableInfo::extra_mac_nodes, ui::AXNodeData::GetIntAttribute(), ui::AXNodeData::GetIntListAttribute(), ax::mojom::kColumn, ax::mojom::kIndirectChildIds, ax::mojom::kTableColumnIndex, ax::mojom::kTableHeaderContainer, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTree::root(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::SetEnableExtraMacNodes().

◆ 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}

References ui::AXTableInfo::extra_mac_nodes, ui::AXNodeData::GetIntAttribute(), ui::AXNodeData::GetIntListAttribute(), ax::mojom::kColumn, ax::mojom::kIgnored, ax::mojom::kIndirectChildIds, ax::mojom::kTableColumnIndex, ax::mojom::kTableHeaderContainer, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::node_id_to_clear, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXNodeData::role, ui::AXTree::root(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTree::SetEnableExtraMacNodes(), and ui::AXTree::Unserialize().

◆ 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}

References ui::AXTableInfo::cell_ids, ui::AXNode::children(), ui::AXTableInfo::col_headers, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTree::root(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTableInfo::row_headers, and ui::AXTableInfo::row_nodes.

◆ 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
1083 AXTreeUpdate update;
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}

References ui::AXTableInfo::col_count, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTree::root(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTableInfo::row_count, ui::AXTableInfo::ToString(), and ui::AXTree::Unserialize().

◆ 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)

References ui::AXTableInfo::cell_id_to_index, ui::AXTableInfo::cell_ids, ui::AXNode::children(), ui::AXTableInfo::col_count, ui::AXTableInfo::col_headers, EXPECT_OPTIONAL_EQ, ui::AXTableInfo::extra_mac_nodes, ui::AXTree::GetFromId(), ui::AXNode::GetTableCellColHeaders(), ui::AXNode::GetTableCellColIndex(), ui::AXNode::GetTableCellColSpan(), ui::AXNode::GetTableCellFromCoords(), ui::AXNode::GetTableCellFromIndex(), ui::AXNode::GetTableCellIndex(), ui::AXNode::GetTableCellRowHeaders(), ui::AXNode::GetTableCellRowIndex(), ui::AXNode::GetTableCellRowSpan(), ui::AXNode::GetTableColCount(), ui::AXNode::GetTableRowCount(), ui::AXNode::GetTableRowNodeIds(), ui::AXNode::GetTableRowRowIndex(), ui::AXNode::id(), ui::AXNode::IsTable(), ui::AXNode::IsTableCellOrHeader(), ui::AXNode::IsTableRow(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTree::root(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTableInfo::row_count, ui::AXTableInfo::row_headers, ui::AXTableInfo::row_nodes, and ui::AXTableInfo::unique_cell_ids.

◆ 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}

References ui::AXTableInfo::cell_ids, ui::AXNode::children(), ui::AXTableInfo::col_count, ax::mojom::kGenericContainer, ax::mojom::kIgnored, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTree::root(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTableInfo::row_count, and ui::AXTableInfo::row_nodes.

◆ 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}

References ui::AXTableInfo::col_count, ax::mojom::kGroup, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTree::root(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTableInfo::row_count, and ui::AXTree::Unserialize().

◆ 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}

References ui::AXTableInfo::col_count, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTree::root(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, ui::AXTableInfo::row_count, ui::AXTableInfo::row_nodes, and ui::AXTree::Unserialize().

◆ 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}

References ui::AXTree::GetFromId(), ui::AXNode::GetTableCellColIndex(), ui::AXNode::GetTableCellFromCoords(), ui::AXNode::GetTableCellFromIndex(), ui::AXNode::GetTableCellRowIndex(), ui::AXNode::GetTableColCount(), ui::AXNode::GetTableRowCount(), ui::AXNode::GetTableRowNodeIds(), ui::AXNode::id(), ui::AXNode::IsTable(), ui::AXNode::IsTableCellOrHeader(), ui::AXNode::IsTableRow(), ax::mojom::kCell, ax::mojom::kColumnHeader, ax::mojom::kRow, ax::mojom::kTable, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTree::root(), and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id.

◆ 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);
682 update.nodes[5].AddIntAttribute(ax::mojom::IntAttribute::kTableCellRowIndex,
683 2);
684 update.nodes[5].AddIntAttribute(
686 update.nodes[6].AddIntAttribute(ax::mojom::IntAttribute::kTableCellRowIndex,
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}

References ui::AXTree::GetFromId(), ui::AXNode::GetTableCellColIndex(), ui::AXNode::GetTableCellFromCoords(), ui::AXNode::GetTableCellRowIndex(), ui::AXNode::GetTableColCount(), ui::AXNode::GetTableRowCount(), ui::AXNode::GetTableRowNodeIds(), ui::AXNode::id(), ax::mojom::kCell, ax::mojom::kColumnHeader, ax::mojom::kRow, ax::mojom::kTable, ax::mojom::kTableCellColumnIndex, ax::mojom::kTableCellRowIndex, ax::mojom::kTableColumnCount, ax::mojom::kTableRowCount, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::nodes, ui::AXTree::root(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTree::Unserialize().

◆ TEST_P() [1/4]

ui::TEST_P ( AXPositionCreatePositionAtTextBoundaryTestWithParam  ,
TextPositionBeforeStaticText   
)

Definition at line 7995 of file ax_node_position_unittest.cc.

7996 {
7997 TestPositionType text_position = AXNodePosition::CreateTextPosition(
7998 GetTreeID(), static_text2_.id, 0 /* text_offset */,
8000 ASSERT_TRUE(text_position->IsTextPosition());
8001 text_position = text_position->CreatePositionAtTextBoundary(
8002 GetParam().boundary, GetParam().direction, GetParam().boundary_behavior);
8003 EXPECT_NE(nullptr, text_position);
8004 EXPECT_EQ(GetParam().expected_text_position, text_position->ToString());
8005}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kDownstream.

◆ TEST_P() [2/4]

ui::TEST_P ( AXPositionExpandToEnclosingTextBoundaryTestWithParam  ,
TextPositionBeforeLine2   
)

Definition at line 7981 of file ax_node_position_unittest.cc.

7982 {
7983 // Create a text position right before "Line 2". This should be at the start
7984 // of many text boundaries, e.g. line, paragraph and word.
7985 TestPositionType text_position = AXNodePosition::CreateTextPosition(
7986 GetTreeID(), text_field_.id, 7 /* text_offset */,
7988 ASSERT_TRUE(text_position->IsTextPosition());
7989 TestPositionRange range = text_position->ExpandToEnclosingTextBoundary(
7990 GetParam().boundary, GetParam().expand_behavior);
7991 EXPECT_EQ(GetParam().expected_anchor_position, range.anchor()->ToString());
7992 EXPECT_EQ(GetParam().expected_focus_position, range.focus()->ToString());
7993}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kDownstream.

◆ TEST_P() [3/4]

ui::TEST_P ( AXPositionTextNavigationTestWithParam  ,
TraverseTreeStartingWithAffinityDownstream   
)

Definition at line 8007 of file ax_node_position_unittest.cc.

8008 {
8009 TestPositionType text_position = AXNodePosition::CreateTextPosition(
8010 GetTreeID(), GetParam().start_node_id, GetParam().start_offset,
8012 ASSERT_TRUE(text_position->IsTextPosition());
8013 for (const std::string& expectation : GetParam().expectations) {
8014 text_position = GetParam().TestMethod(text_position);
8015 EXPECT_NE(nullptr, text_position);
8016 EXPECT_EQ(expectation, text_position->ToString());
8017 }
8018}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kDownstream.

◆ TEST_P() [4/4]

ui::TEST_P ( AXPositionTextNavigationTestWithParam  ,
TraverseTreeStartingWithAffinityUpstream   
)

Definition at line 8020 of file ax_node_position_unittest.cc.

8021 {
8022 TestPositionType text_position = AXNodePosition::CreateTextPosition(
8023 GetTreeID(), GetParam().start_node_id, GetParam().start_offset,
8025 ASSERT_TRUE(text_position->IsTextPosition());
8026 for (const std::string& expectation : GetParam().expectations) {
8027 text_position = GetParam().TestMethod(text_position);
8028 EXPECT_NE(nullptr, text_position);
8029 EXPECT_EQ(expectation, text_position->ToString());
8030 }
8031}

References ui::AXPosition< AXNodePosition, AXNode >::CreateTextPosition(), and ax::mojom::kUpstream.

◆ 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}

References i, ui::AXNodeData::ToString(), and value.

◆ 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}

References i, ui::AXNodeData::ToString(), and value.

◆ 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}

◆ 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}

References action, ax::mojom::kAnnotatePageImages, ax::mojom::kBlur, ax::mojom::kClearAccessibilityFocus, ax::mojom::kCollapse, ax::mojom::kCustomAction, ax::mojom::kDecrement, ax::mojom::kDoDefault, ax::mojom::kExpand, ax::mojom::kFocus, ax::mojom::kGetImageData, ax::mojom::kGetTextLocation, ax::mojom::kHideTooltip, ax::mojom::kHitTest, ax::mojom::kIncrement, ax::mojom::kInternalInvalidateTree, ax::mojom::kLoadInlineTextBoxes, ax::mojom::kNone, ax::mojom::kReplaceSelectedText, ax::mojom::kScrollBackward, ax::mojom::kScrollDown, ax::mojom::kScrollForward, ax::mojom::kScrollLeft, ax::mojom::kScrollRight, ax::mojom::kScrollToMakeVisible, ax::mojom::kScrollToPoint, ax::mojom::kScrollUp, ax::mojom::kSetAccessibilityFocus, ax::mojom::kSetScrollOffset, ax::mojom::kSetSelection, ax::mojom::kSetSequentialFocusNavigationStartingPoint, ax::mojom::kSetValue, ax::mojom::kShowContextMenu, ax::mojom::kShowTooltip, and ax::mojom::kSignalEndOfTest.

◆ 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}

References ax::mojom::kNone, ax::mojom::kRequestImages, and ax::mojom::kRequestInlineTextBoxes.

◆ ToString() [3/39]

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

Definition at line 2417 of file ax_enum_util.cc.

2417 {
2418 switch (aria_current_state) {
2420 return "none";
2422 return "false";
2424 return "true";
2426 return "page";
2428 return "step";
2430 return "location";
2432 return "unclippedLocation";
2434 return "date";
2436 return "time";
2437 }
2438
2439 return "";
2440}

References ax::mojom::kDate, ax::mojom::kFalse, ax::mojom::kLocation, ax::mojom::kNone, ax::mojom::kPage, ax::mojom::kStep, ax::mojom::kTime, ax::mojom::kTrue, and ax::mojom::kUnclippedLocation.

◆ ToString() [4/39]

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

Definition at line 1829 of file ax_enum_util.cc.

1829 {
1830 switch (bool_attribute) {
1832 return "none";
1834 return "busy";
1836 return "editableRoot";
1838 return "containerLiveAtomic";
1840 return "containerLiveBusy";
1842 return "grabbed";
1844 return "liveAtomic";
1846 return "modal";
1848 return "updateLocationOnly";
1850 return "canvasHasFallback";
1852 return "scrollable";
1854 return "clickable";
1856 return "clipsChildren";
1858 return "notUserSelectableStyle";
1860 return "selected";
1862 return "selectedFromFocus";
1864 return "supportsTextLocation";
1866 return "isLineBreakingObject";
1868 return "isPageBreakingObject";
1870 return "hasAriaAttribute";
1871 }
1872
1873 return "";
1874}

References ax::mojom::kBusy, ax::mojom::kCanvasHasFallback, ax::mojom::kClickable, ax::mojom::kClipsChildren, ax::mojom::kContainerLiveAtomic, ax::mojom::kContainerLiveBusy, ax::mojom::kEditableRoot, ax::mojom::kGrabbed, ax::mojom::kHasAriaAttribute, ax::mojom::kIsLineBreakingObject, ax::mojom::kIsPageBreakingObject, ax::mojom::kLiveAtomic, ax::mojom::kModal, ax::mojom::kNone, ax::mojom::kNotUserSelectableStyle, ax::mojom::kScrollable, ax::mojom::kSelected, ax::mojom::kSelectedFromFocus, ax::mojom::kSupportsTextLocation, and ax::mojom::kUpdateLocationOnly.

◆ ToString() [5/39]

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

Definition at line 2553 of file ax_enum_util.cc.

2553 {
2554 switch (checked_state) {
2556 return "none";
2558 return "false";
2560 return "true";
2562 return "mixed";
2563 }
2564
2565 return "";
2566}

References ax::mojom::kFalse, ax::mojom::kMixed, ax::mojom::kNone, and ax::mojom::kTrue.

◆ ToString() [6/39]

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

Definition at line 2109 of file ax_enum_util.cc.

2109 {
2110 switch (command) {
2112 return "clearSelection";
2114 return "cut";
2116 return "delete";
2118 return "dictate";
2120 return "extendSelection";
2122 return "format";
2124 return "insert";
2126 return "marker";
2128 return "moveSelection";
2130 return "paste";
2132 return "replace";
2134 return "setSelection";
2136 return "type";
2137 }
2138
2139 return "";
2140}

References ax::mojom::kClearSelection, ax::mojom::kCut, ax::mojom::kDelete, ax::mojom::kDictate, ax::mojom::kExtendSelection, ax::mojom::kFormat, ax::mojom::kInsert, ax::mojom::kMarker, ax::mojom::kMoveSelection, ax::mojom::kPaste, ax::mojom::kReplace, ax::mojom::kSetSelection, and ax::mojom::kType.

◆ 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}

References ax::mojom::kActivate, ax::mojom::kCheck, ax::mojom::kClick, ax::mojom::kClickAncestor, ax::mojom::kJump, ax::mojom::kNone, ax::mojom::kOpen, ax::mojom::kPress, ax::mojom::kSelect, and ax::mojom::kUncheck.

◆ ToString() [8/39]

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

Definition at line 2662 of file ax_enum_util.cc.

2662 {
2663 switch (description_from) {
2665 return "none";
2667 return "uninitialized";
2669 return "attribute";
2671 return "contents";
2673 return "relatedElement";
2675 return "title";
2676 }
2677
2678 return "";
2679}

References ax::mojom::kAttribute, ax::mojom::kContents, ax::mojom::kNone, ax::mojom::kRelatedElement, ax::mojom::kTitle, and ax::mojom::kUninitialized.

◆ ToString() [9/39]

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

Definition at line 2930 of file ax_enum_util.cc.

2930 {
2931 switch (dropeffect) {
2933 return "copy";
2935 return "execute";
2937 return "link";
2939 return "move";
2941 return "popup";
2943 return "none";
2944 }
2945
2946 return "";
2947}

References ax::mojom::kCopy, ax::mojom::kExecute, ax::mojom::kLink, ax::mojom::kMove, ax::mojom::kNone, and ax::mojom::kPopup.

◆ 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}

References ax::mojom::kActiveDescendantChanged, ax::mojom::kAlert, ax::mojom::kAriaAttributeChanged, ax::mojom::kAutocorrectionOccured, ax::mojom::kBlur, ax::mojom::kCheckedStateChanged, ax::mojom::kChildrenChanged, ax::mojom::kClicked, ax::mojom::kControlsChanged, ax::mojom::kDocumentSelectionChanged, ax::mojom::kDocumentTitleChanged, ax::mojom::kEndOfTest, ax::mojom::kExpandedChanged, ax::mojom::kFocus, ax::mojom::kFocusAfterMenuClose, ax::mojom::kFocusContext, ax::mojom::kHide, ax::mojom::kHitTestResult, ax::mojom::kHover, ax::mojom::kImageFrameUpdated, ax::mojom::kInvalidStatusChanged, ax::mojom::kLayoutComplete, ax::mojom::kLiveRegionChanged, ax::mojom::kLiveRegionCreated, ax::mojom::kLoadComplete, ax::mojom::kLoadStart, ax::mojom::kLocationChanged, ax::mojom::kMediaStartedPlaying, ax::mojom::kMediaStoppedPlaying, ax::mojom::kMenuEnd, ax::mojom::kMenuListItemSelected, ax::mojom::kMenuListValueChanged, ax::mojom::kMenuPopupEnd, ax::mojom::kMenuPopupStart, ax::mojom::kMenuStart, ax::mojom::kMouseCanceled, ax::mojom::kMouseDragged, ax::mojom::kMouseMoved, ax::mojom::kMousePressed, ax::mojom::kMouseReleased, ax::mojom::kNone, ax::mojom::kRowCollapsed, ax::mojom::kRowCountChanged, ax::mojom::kRowExpanded, ax::mojom::kScrolledToAnchor, ax::mojom::kScrollPositionChanged, ax::mojom::kSelectedChildrenChanged, ax::mojom::kSelection, ax::mojom::kSelectionAdd, ax::mojom::kSelectionRemove, ax::mojom::kShow, ax::mojom::kStateChanged, ax::mojom::kTextChanged, ax::mojom::kTextSelectionChanged, ax::mojom::kTooltipClosed, ax::mojom::kTooltipOpened, ax::mojom::kTreeChanged, ax::mojom::kValueChanged, ax::mojom::kWindowActivated, ax::mojom::kWindowDeactivated, and ax::mojom::kWindowVisibilityChanged.

Referenced by ui::AXNodeData::DropeffectBitfieldToString(), ui::AXPlatformNode::IsDescendantOf(), operator<<(), ui::AXTreeID::operator=(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), ui::AXEventIntent::ToString(), ui::AXNodeData::ToString(), ui::AXPosition< AXPositionType, AXNodeType >::ToString(), ui::AXTreeData::ToString(), ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::ToString(), ui::AXNodeData::~AXNodeData(), and ui::AXTreeData::~AXTreeData().

◆ ToString() [11/39]

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

Definition at line 2697 of file ax_enum_util.cc.

2697 {
2698 switch (event_from) {
2700 return "none";
2702 return "user";
2704 return "page";
2706 return "action";
2707 }
2708
2709 return "";
2710}

References ax::mojom::kAction, ax::mojom::kNone, ax::mojom::kPage, and ax::mojom::kUser.

◆ ToString() [12/39]

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

Definition at line 1786 of file ax_enum_util.cc.

1786 {
1787 switch (float_attribute) {
1789 return "none";
1791 return "valueForRange";
1793 return "minValueForRange";
1795 return "maxValueForRange";
1797 return "stepValueForRange";
1799 return "fontSize";
1801 return "fontWeight";
1803 return "textIndent";
1804 }
1805
1806 return "";
1807}

References ax::mojom::kFontSize, ax::mojom::kFontWeight, ax::mojom::kMaxValueForRange, ax::mojom::kMinValueForRange, ax::mojom::kNone, ax::mojom::kStepValueForRange, ax::mojom::kTextIndent, and ax::mojom::kValueForRange.

◆ ToString() [13/39]

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

Definition at line 2724 of file ax_enum_util.cc.

2724 {
2725 switch (gesture) {
2727 return "none";
2729 return "click";
2731 return "swipeLeft1";
2733 return "swipeUp1";
2735 return "swipeRight1";
2737 return "swipeDown1";
2739 return "swipeLeft2";
2741 return "swipeUp2";
2743 return "swipeRight2";
2745 return "swipeDown2";
2747 return "swipeLeft3";
2749 return "swipeUp3";
2751 return "swipeRight3";
2753 return "swipeDown3";
2755 return "swipeLeft4";
2757 return "swipeUp4";
2759 return "swipeRight4";
2761 return "swipeDown4";
2763 return "tap2";
2765 return "tap3";
2767 return "tap4";
2769 return "touchExplore";
2770 }
2771
2772 return "";
2773}

References ax::mojom::kClick, ax::mojom::kNone, ax::mojom::kSwipeDown1, ax::mojom::kSwipeDown2, ax::mojom::kSwipeDown3, ax::mojom::kSwipeDown4, ax::mojom::kSwipeLeft1, ax::mojom::kSwipeLeft2, ax::mojom::kSwipeLeft3, ax::mojom::kSwipeLeft4, ax::mojom::kSwipeRight1, ax::mojom::kSwipeRight2, ax::mojom::kSwipeRight3, ax::mojom::kSwipeRight4, ax::mojom::kSwipeUp1, ax::mojom::kSwipeUp2, ax::mojom::kSwipeUp3, ax::mojom::kSwipeUp4, ax::mojom::kTap2, ax::mojom::kTap3, ax::mojom::kTap4, and ax::mojom::kTouchExplore.

◆ ToString() [14/39]

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

Definition at line 2465 of file ax_enum_util.cc.

2465 {
2466 switch (has_popup) {
2468 return "";
2470 return "true";
2472 return "menu";
2474 return "listbox";
2476 return "tree";
2478 return "grid";
2480 return "dialog";
2481 }
2482
2483 return "";
2484}

References ax::mojom::kDialog, ax::mojom::kFalse, ax::mojom::kGrid, ax::mojom::kListbox, ax::mojom::kMenu, ax::mojom::kTree, and ax::mojom::kTrue.

◆ ToString() [15/39]

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

Definition at line 2877 of file ax_enum_util.cc.

2877 {
2878 switch (status) {
2880 return "none";
2882 return "kWillNotAnnotateDueToScheme";
2884 return "ineligibleForAnnotation";
2886 return "eligibleForAnnotation";
2888 return "silentlyEligibleForAnnotation";
2890 return "annotationPending";
2892 return "annotationSucceeded";
2894 return "annotationEmpty";
2896 return "annotationAdult";
2898 return "annotationProcessFailed";
2899 }
2900
2901 return "";
2902}

References ax::mojom::kAnnotationAdult, ax::mojom::kAnnotationEmpty, ax::mojom::kAnnotationPending, ax::mojom::kAnnotationProcessFailed, ax::mojom::kAnnotationSucceeded, ax::mojom::kEligibleForAnnotation, ax::mojom::kIneligibleForAnnotation, ax::mojom::kNone, ax::mojom::kSilentlyEligibleForAnnotation, and ax::mojom::kWillNotAnnotateDueToScheme.

◆ ToString() [16/39]

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

Definition at line 1531 of file ax_enum_util.cc.

1531 {
1532 switch (int_attribute) {
1534 return "none";
1536 return "defaultActionVerb";
1538 return "dropeffect";
1540 return "scrollX";
1542 return "scrollXMin";
1544 return "scrollXMax";
1546 return "scrollY";
1548 return "scrollYMin";
1550 return "scrollYMax";
1552 return "textSelStart";
1554 return "textSelEnd";
1556 return "ariaColumnCount";
1558 return "ariaCellColumnIndex";
1560 return "ariaCellColumnSpan";
1562 return "ariaRowCount";
1564 return "ariaCellRowIndex";
1566 return "ariaCellRowSpan";
1568 return "tableRowCount";
1570 return "tableColumnCount";
1572 return "tableHeaderId";
1574 return "tableRowIndex";
1576 return "tableRowHeaderId";
1578 return "tableColumnIndex";
1580 return "tableColumnHeaderId";
1582 return "tableCellColumnIndex";
1584 return "tableCellColumnSpan";
1586 return "tableCellRowIndex";
1588 return "tableCellRowSpan";
1590 return "sortDirection";
1592 return "hierarchicalLevel";
1594 return "nameFrom";
1596 return "descriptionFrom";
1598 return "activedescendantId";
1600 return "errormessageId";
1602 return "inPageLinkTargetId";
1604 return "memberOfId";
1606 return "nextOnLineId";
1608 return "popupForId";
1610 return "previousOnLineId";
1612 return "restriction";
1614 return "setSize";
1616 return "posInSet";
1618 return "colorValue";
1620 return "ariaCurrentState";
1622 return "backgroundColor";
1624 return "color";
1626 return "haspopup";
1628 return "invalidState";
1630 return "checkedState";
1632 return "listStyle";
1634 return "text-align";
1636 return "textDirection";
1638 return "textPosition";
1640 return "textStyle";
1642 return "textOverlineStyle";
1644 return "textStrikethroughStyle";
1646 return "textUnderlineStyle";
1648 return "previousFocusId";
1650 return "nextFocusId";
1652 return "imageAnnotationStatus";
1654 return "domNodeId";
1655 }
1656
1657 return "";
1658}

References ax::mojom::kActivedescendantId, ax::mojom::kAriaCellColumnIndex, ax::mojom::kAriaCellColumnSpan, ax::mojom::kAriaCellRowIndex, ax::mojom::kAriaCellRowSpan, ax::mojom::kAriaColumnCount, ax::mojom::kAriaCurrentState, ax::mojom::kAriaRowCount, ax::mojom::kBackgroundColor, ax::mojom::kCheckedState, ax::mojom::kColor, ax::mojom::kColorValue, ax::mojom::kDefaultActionVerb, ax::mojom::kDescriptionFrom, ax::mojom::kDOMNodeId, ax::mojom::kDropeffect, ax::mojom::kErrormessageId, ax::mojom::kHasPopup, ax::mojom::kHierarchicalLevel, ax::mojom::kImageAnnotationStatus, ax::mojom::kInPageLinkTargetId, ax::mojom::kInvalidState, ax::mojom::kListStyle, ax::mojom::kMemberOfId, ax::mojom::kNameFrom, ax::mojom::kNextFocusId, ax::mojom::kNextOnLineId, ax::mojom::kNone, ax::mojom::kPopupForId, ax::mojom::kPosInSet, ax::mojom::kPreviousFocusId, ax::mojom::kPreviousOnLineId, ax::mojom::kRestriction, ax::mojom::kScrollX, ax::mojom::kScrollXMax, ax::mojom::kScrollXMin, ax::mojom::kScrollY, ax::mojom::kScrollYMax, ax::mojom::kScrollYMin, ax::mojom::kSetSize, ax::mojom::kSortDirection, ax::mojom::kTableCellColumnIndex, ax::mojom::kTableCellColumnSpan, ax::mojom::kTableCellRowIndex, ax::mojom::kTableCellRowSpan, ax::mojom::kTableColumnCount, ax::mojom::kTableColumnHeaderId, ax::mojom::kTableColumnIndex, ax::mojom::kTableHeaderId, ax::mojom::kTableRowCount, ax::mojom::kTableRowHeaderId, ax::mojom::kTableRowIndex, ax::mojom::kTextAlign, ax::mojom::kTextDirection, ax::mojom::kTextOverlineStyle, ax::mojom::kTextPosition, ax::mojom::kTextSelEnd, ax::mojom::kTextSelStart, ax::mojom::kTextStrikethroughStyle, ax::mojom::kTextStyle, and ax::mojom::kTextUnderlineStyle.

◆ ToString() [17/39]

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

Definition at line 1920 of file ax_enum_util.cc.

1920 {
1921 switch (int_list_attribute) {
1923 return "none";
1925 return "indirectChildIds";
1927 return "controlsIds";
1929 return "detailsIds";
1931 return "describedbyIds";
1933 return "flowtoIds";
1935 return "labelledbyIds";
1937 return "radioGroupIds";
1939 return "markerTypes";
1941 return "markerStarts";
1943 return "markerEnds";
1945 return "characterOffsets";
1947 return "cachedLineStarts";
1949 return "wordStarts";
1951 return "wordEnds";
1953 return "customActionIds";
1954 }
1955
1956 return "";
1957}

References ax::mojom::kCachedLineStarts, ax::mojom::kCharacterOffsets, ax::mojom::kControlsIds, ax::mojom::kCustomActionIds, ax::mojom::kDescribedbyIds, ax::mojom::kDetailsIds, ax::mojom::kFlowtoIds, ax::mojom::kIndirectChildIds, ax::mojom::kLabelledbyIds, ax::mojom::kMarkerEnds, ax::mojom::kMarkerStarts, ax::mojom::kMarkerTypes, ax::mojom::kNone, ax::mojom::kRadioGroupIds, ax::mojom::kWordEnds, and ax::mojom::kWordStarts.

◆ ToString() [18/39]

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

Definition at line 2503 of file ax_enum_util.cc.

2503 {
2504 switch (invalid_state) {
2506 return "none";
2508 return "false";
2510 return "true";
2512 return "other";
2513 }
2514
2515 return "";
2516}

References ax::mojom::kFalse, ax::mojom::kNone, ax::mojom::kOther, and ax::mojom::kTrue.

◆ ToString() [19/39]

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

Definition at line 2016 of file ax_enum_util.cc.

2016 {
2017 switch (list_style) {
2019 return "none";
2021 return "circle";
2023 return "disc";
2025 return "image";
2027 return "numeric";
2029 return "other";
2031 return "square";
2032 }
2033
2034 return "";
2035}

References ax::mojom::kCircle, ax::mojom::kDisc, ax::mojom::kImage, ax::mojom::kNone, ax::mojom::kNumeric, ax::mojom::kOther, and ax::mojom::kSquare.

◆ ToString() [20/39]

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

Definition at line 2055 of file ax_enum_util.cc.

2055 {
2056 switch (marker_type) {
2058 return "none";
2060 return "spelling";
2062 return "grammar";
2064 return "textMatch";
2066 return "activeSuggestion";
2068 return "suggestion";
2069 }
2070
2071 return "";
2072}

References ax::mojom::kActiveSuggestion, ax::mojom::kGrammar, ax::mojom::kNone, ax::mojom::kSpelling, ax::mojom::kSuggestion, and ax::mojom::kTextMatch.

◆ ToString() [21/39]

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

Definition at line 2090 of file ax_enum_util.cc.

2090 {
2091 switch (move_direction) {
2093 return "forward";
2095 return "backward";
2096 }
2097
2098 return "";
2099}

References ax::mojom::kBackward, and ax::mojom::kForward.

◆ 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}

References ax::mojom::kNodeChanged, ax::mojom::kNodeCreated, ax::mojom::kNodeRemoved, ax::mojom::kNone, and ax::mojom::kSubtreeCreated.

◆ ToString() [23/39]

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

Definition at line 2611 of file ax_enum_util.cc.

2611 {
2612 switch (name_from) {
2614 return "none";
2616 return "uninitialized";
2618 return "attribute";
2620 return "attributeExplicitlyEmpty";
2622 return "caption";
2624 return "contents";
2626 return "placeholder";
2628 return "relatedElement";
2630 return "title";
2632 return "value";
2633 }
2634
2635 return "";
2636}

References ax::mojom::kAttribute, ax::mojom::kAttributeExplicitlyEmpty, ax::mojom::kCaption, ax::mojom::kContents, ax::mojom::kNone, ax::mojom::kPlaceholder, ax::mojom::kRelatedElement, ax::mojom::kTitle, ax::mojom::kUninitialized, and ax::mojom::kValue.

◆ ToString() [24/39]

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

Definition at line 2530 of file ax_enum_util.cc.

2530 {
2531 switch (restriction) {
2533 return "none";
2535 return "readOnly";
2537 return "disabled";
2538 }
2539
2540 return "";
2541}

References ax::mojom::kDisabled, ax::mojom::kNone, and ax::mojom::kReadOnly.

◆ 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}

References ax::mojom::kAbbr, ax::mojom::kAlert, ax::mojom::kAlertDialog, ax::mojom::kAnchor, ax::mojom::kApplication, ax::mojom::kArticle, ax::mojom::kAudio, ax::mojom::kBanner, ax::mojom::kBlockquote, ax::mojom::kButton, ax::mojom::kCanvas, ax::mojom::kCaption, ax::mojom::kCaret, ax::mojom::kCell, ax::mojom::kCheckBox, ax::mojom::kClient, ax::mojom::kCode, ax::mojom::kColorWell, ax::mojom::kColumn, ax::mojom::kColumnHeader, ax::mojom::kComboBoxGrouping, ax::mojom::kComboBoxMenuButton, ax::mojom::kComment, ax::mojom::kComplementary, ax::mojom::kContentDeletion, ax::mojom::kContentInfo, ax::mojom::kContentInsertion, ax::mojom::kDate, ax::mojom::kDateTime, ax::mojom::kDefinition, ax::mojom::kDescriptionList, ax::mojom::kDescriptionListDetail, ax::mojom::kDescriptionListTerm, ax::mojom::kDesktop, ax::mojom::kDetails, ax::mojom::kDialog, ax::mojom::kDirectory, ax::mojom::kDisclosureTriangle, ax::mojom::kDocAbstract, ax::mojom::kDocAcknowledgments, ax::mojom::kDocAfterword, ax::mojom::kDocAppendix, ax::mojom::kDocBackLink, ax::mojom::kDocBiblioEntry, ax::mojom::kDocBibliography, ax::mojom::kDocBiblioRef, ax::mojom::kDocChapter, ax::mojom::kDocColophon, ax::mojom::kDocConclusion, ax::mojom::kDocCover, ax::mojom::kDocCredit, ax::mojom::kDocCredits, ax::mojom::kDocDedication, ax::mojom::kDocEndnote, ax::mojom::kDocEndnotes, ax::mojom::kDocEpigraph, ax::mojom::kDocEpilogue, ax::mojom::kDocErrata, ax::mojom::kDocExample, ax::mojom::kDocFootnote, ax::mojom::kDocForeword, ax::mojom::kDocGlossary, ax::mojom::kDocGlossRef, ax::mojom::kDocIndex, ax::mojom::kDocIntroduction, ax::mojom::kDocNoteRef, ax::mojom::kDocNotice, ax::mojom::kDocPageBreak, ax::mojom::kDocPageList, ax::mojom::kDocPart, ax::mojom::kDocPreface, ax::mojom::kDocPrologue, ax::mojom::kDocPullquote, ax::mojom::kDocQna, ax::mojom::kDocSubtitle, ax::mojom::kDocTip, ax::mojom::kDocToc, ax::mojom::kDocument, ax::mojom::kEmbeddedObject, ax::mojom::kEmphasis, ax::mojom::kFeed, ax::mojom::kFigcaption, ax::mojom::kFigure, ax::mojom::kFooter, ax::mojom::kFooterAsNonLandmark, ax::mojom::kForm, ax::mojom::kGenericContainer, ax::mojom::kGraphicsDocument, ax::mojom::kGraphicsObject, ax::mojom::kGraphicsSymbol, ax::mojom::kGrid, ax::mojom::kGroup, ax::mojom::kHeader, ax::mojom::kHeaderAsNonLandmark, ax::mojom::kHeading, ax::mojom::kIframe, ax::mojom::kIframePresentational, ax::mojom::kIgnored, ax::mojom::kImage, ax::mojom::kImageMap, ax::mojom::kImeCandidate, ax::mojom::kInlineTextBox, ax::mojom::kInputTime, ax::mojom::kKeyboard, ax::mojom::kLabelText, ax::mojom::kLayoutTable, ax::mojom::kLayoutTableCell, ax::mojom::kLayoutTableRow, ax::mojom::kLegend, ax::mojom::kLineBreak, ax::mojom::kLink, ax::mojom::kList, ax::mojom::kListBox, ax::mojom::kListBoxOption, ax::mojom::kListGrid, ax::mojom::kListItem, ax::mojom::kListMarker, ax::mojom::kLog, ax::mojom::kMain, ax::mojom::kMark, ax::mojom::kMarquee, ax::mojom::kMath, ax::mojom::kMenu, ax::mojom::kMenuBar, ax::mojom::kMenuItem, ax::mojom::kMenuItemCheckBox, ax::mojom::kMenuItemRadio, ax::mojom::kMenuListOption, ax::mojom::kMenuListPopup, ax::mojom::kMeter, ax::mojom::kNavigation, ax::mojom::kNone, ax::mojom::kNote, ax::mojom::kPane, ax::mojom::kParagraph, ax::mojom::kPdfActionableHighlight, ax::mojom::kPluginObject, ax::mojom::kPopUpButton, ax::mojom::kPortal, ax::mojom::kPre, ax::mojom::kPresentational, ax::mojom::kProgressIndicator, ax::mojom::kRadioButton, ax::mojom::kRadioGroup, ax::mojom::kRegion, ax::mojom::kRootWebArea, ax::mojom::kRow, ax::mojom::kRowGroup, ax::mojom::kRowHeader, ax::mojom::kRuby, ax::mojom::kRubyAnnotation, ax::mojom::kScrollBar, ax::mojom::kScrollView, ax::mojom::kSearch, ax::mojom::kSearchBox, ax::mojom::kSection, ax::mojom::kSlider, ax::mojom::kSliderThumb, ax::mojom::kSpinButton, ax::mojom::kSplitter, ax::mojom::kStaticText, ax::mojom::kStatus, ax::mojom::kStrong, ax::mojom::kSuggestion, ax::mojom::kSvgRoot, ax::mojom::kSwitch, ax::mojom::kTab, ax::mojom::kTable, ax::mojom::kTableHeaderContainer, ax::mojom::kTabList, ax::mojom::kTabPanel, ax::mojom::kTerm, ax::mojom::kTextField, ax::mojom::kTextFieldWithComboBox, ax::mojom::kTime, ax::mojom::kTimer, ax::mojom::kTitleBar, ax::mojom::kToggleButton, ax::mojom::kToolbar, ax::mojom::kTooltip, ax::mojom::kTree, ax::mojom::kTreeGrid, ax::mojom::kTreeItem, ax::mojom::kUnknown, ax::mojom::kVideo, ax::mojom::kWebArea, ax::mojom::kWebView, and ax::mojom::kWindow.

◆ 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}

References ax::mojom::kNone, ax::mojom::kScrollAlignmentBottom, ax::mojom::kScrollAlignmentCenter, ax::mojom::kScrollAlignmentClosestEdge, ax::mojom::kScrollAlignmentLeft, ax::mojom::kScrollAlignmentRight, and ax::mojom::kScrollAlignmentTop.

◆ ToString() [27/39]

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

Definition at line 2580 of file ax_enum_util.cc.

2580 {
2581 switch (sort_direction) {
2583 return "none";
2585 return "unsorted";
2587 return "ascending";
2589 return "descending";
2591 return "other";
2592 }
2593
2594 return "";
2595}

References ax::mojom::kAscending, ax::mojom::kDescending, ax::mojom::kNone, ax::mojom::kOther, and ax::mojom::kUnsorted.

◆ 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}

References ax::mojom::kAutofillAvailable, ax::mojom::kCollapsed, ax::mojom::kDefault, ax::mojom::kEditable, ax::mojom::kExpanded, ax::mojom::kFocusable, ax::mojom::kHorizontal, ax::mojom::kHovered, ax::mojom::kIgnored, ax::mojom::kInvisible, ax::mojom::kLinked, ax::mojom::kMultiline, ax::mojom::kMultiselectable, ax::mojom::kNone, ax::mojom::kProtected, ax::mojom::kRequired, ax::mojom::kRichlyEditable, ax::mojom::kVertical, and ax::mojom::kVisited.

◆ 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 "identifier";
1437 return "imageAnnotation";
1439 return "imageDataUrl";
1441 return "innerHtml";
1443 return "inputType";
1445 return "keyShortcuts";
1447 return "language";
1449 return "name";
1451 return "liveRelevant";
1453 return "liveStatus";
1455 return "placeholder";
1457 return "role";
1459 return "roleDescription";
1461 return "tooltip";
1463 return "url";
1465 return "value";
1466 }
1467
1468 return "";
1469}

References ax::mojom::kAccessKey, ax::mojom::kAriaInvalidValue, ax::mojom::kAutoComplete, ax::mojom::kChildTreeId, ax::mojom::kClassName, ax::mojom::kContainerLiveRelevant, ax::mojom::kContainerLiveStatus, ax::mojom::kDescription, ax::mojom::kDisplay, ax::mojom::kFontFamily, ax::mojom::kHtmlTag, ax::mojom::kIdentifier, ax::mojom::kImageAnnotation, ax::mojom::kImageDataUrl, ax::mojom::kInnerHtml, ax::mojom::kInputType, ax::mojom::kKeyShortcuts, ax::mojom::kLanguage, ax::mojom::kLiveRelevant, ax::mojom::kLiveStatus, ax::mojom::kName, ax::mojom::kNone, ax::mojom::kPlaceholder, ax::mojom::kRole, ax::mojom::kRoleDescription, ax::mojom::kTooltip, ax::mojom::kUrl, and ax::mojom::kValue.

◆ ToString() [30/39]

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

Definition at line 1996 of file ax_enum_util.cc.

1996 {
1997 switch (string_list_attribute) {
1999 return "none";
2001 return "customActionDescriptions";
2002 }
2003
2004 return "";
2005}

References ax::mojom::kCustomActionDescriptions, and ax::mojom::kNone.

◆ ToString() [31/39]

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

Definition at line 2823 of file ax_enum_util.cc.

2823 {
2824 switch (text_affinity) {
2826 return "none";
2828 return "downstream";
2830 return "upstream";
2831 }
2832
2833 return "";
2834}

References ax::mojom::kDownstream, ax::mojom::kNone, and ax::mojom::kUpstream.

◆ ToString() [32/39]

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

Definition at line 2297 of file ax_enum_util.cc.

2297 {
2298 switch (text_align) {
2300 return "none";
2302 return "left";
2304 return "right";
2306 return "center";
2308 return "justify";
2309 }
2310
2311 return "";
2312}

References ax::mojom::kCenter, ax::mojom::kJustify, ax::mojom::kLeft, ax::mojom::kNone, and ax::mojom::kRight.

◆ ToString() [33/39]

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

Definition at line 2174 of file ax_enum_util.cc.

2174 {
2175 switch (text_boundary) {
2177 return "character";
2179 return "format";
2181 return "lineEnd";
2183 return "lineStart";
2185 return "lineStartOrEnd";
2187 return "object";
2189 return "pageEnd";
2191 return "pageStart";
2193 return "pageStartOrEnd";
2195 return "paragraphEnd";
2197 return "paragraphStart";
2199 return "paragraphStartOrEnd";
2201 return "sentenceEnd";
2203 return "sentenceStart";
2205 return "sentenceStartOrEnd";
2207 return "webPage";
2209 return "wordEnd";
2211 return "wordStart";
2213 return "wordStartOrEnd";
2214 }
2215
2216 return "";
2217}

References ax::mojom::kCharacter, ax::mojom::kFormat, ax::mojom::kLineEnd, ax::mojom::kLineStart, ax::mojom::kLineStartOrEnd, ax::mojom::kObject, ax::mojom::kPageEnd, ax::mojom::kPageStart, ax::mojom::kPageStartOrEnd, ax::mojom::kParagraphEnd, ax::mojom::kParagraphStart, ax::mojom::kParagraphStartOrEnd, ax::mojom::kSentenceEnd, ax::mojom::kSentenceStart, ax::mojom::kSentenceStartOrEnd, ax::mojom::kWebPage, ax::mojom::kWordEnd, ax::mojom::kWordStart, and ax::mojom::kWordStartOrEnd.

◆ ToString() [34/39]

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

Definition at line 2261 of file ax_enum_util.cc.

2261 {
2262 switch (text_decoration_style) {
2264 return "none";
2266 return "solid";
2268 return "dashed";
2270 return "dotted";
2272 return "double";
2274 return "wavy";
2275 }
2276
2277 return "";
2278}

References ax::mojom::kDashed, ax::mojom::kDotted, ax::mojom::kDouble, ax::mojom::kNone, ax::mojom::kSolid, and ax::mojom::kWavy.

◆ ToString() [35/39]

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

Definition at line 2359 of file ax_enum_util.cc.

2359 {
2360 switch (text_position) {
2362 return "none";
2364 return "subscript";
2366 return "superscript";
2367 }
2368
2369 return "";
2370}

References ax::mojom::kNone, ax::mojom::kSubscript, and ax::mojom::kSuperscript.

◆ ToString() [36/39]

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

Definition at line 2382 of file ax_enum_util.cc.

2382 {
2383 switch (text_style) {
2385 return "none";
2387 return "bold";
2389 return "italic";
2391 return "underline";
2393 return "lineThrough";
2395 return "overline";
2396 }
2397
2398 return "";
2399}

References ax::mojom::kBold, ax::mojom::kItalic, ax::mojom::kLineThrough, ax::mojom::kNone, ax::mojom::kOverline, and ax::mojom::kUnderline.

◆ ToString() [37/39]

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

Definition at line 2846 of file ax_enum_util.cc.

2846 {
2847 switch (tree_order) {
2849 return "none";
2851 return "undefined";
2853 return "before";
2855 return "equal";
2857 return "after";
2858 }
2859
2860 return "";
2861}

References ax::mojom::kAfter, ax::mojom::kBefore, ax::mojom::kEqual, ax::mojom::kNone, and ax::mojom::kUndefined.

◆ ToString() [38/39]

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

Definition at line 2328 of file ax_enum_util.cc.

2328 {
2329 switch (text_direction) {
2331 return "none";
2333 return "ltr";
2335 return "rtl";
2337 return "ttb";
2339 return "btt";
2340 }
2341
2342 return "";
2343}

References ax::mojom::kBtt, ax::mojom::kLtr, ax::mojom::kNone, ax::mojom::kRtl, and ax::mojom::kTtb.

◆ 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}

References ui::AXEventGenerator::ACCESS_KEY_CHANGED, ui::AXEventGenerator::ACTIVE_DESCENDANT_CHANGED, ui::AXEventGenerator::ALERT, ui::AXEventGenerator::ATK_TEXT_OBJECT_ATTRIBUTE_CHANGED, ui::AXEventGenerator::ATOMIC_CHANGED, ui::AXEventGenerator::AUTO_COMPLETE_CHANGED, BASE_UNREACHABLE, ui::AXEventGenerator::BUSY_CHANGED, ui::AXEventGenerator::CHECKED_STATE_CHANGED, ui::AXEventGenerator::CHILDREN_CHANGED, ui::AXEventGenerator::CLASS_NAME_CHANGED, ui::AXEventGenerator::COLLAPSED, ui::AXEventGenerator::CONTROLS_CHANGED, ui::AXEventGenerator::DESCRIBED_BY_CHANGED, ui::AXEventGenerator::DESCRIPTION_CHANGED, ui::AXEventGenerator::DOCUMENT_SELECTION_CHANGED, ui::AXEventGenerator::DOCUMENT_TITLE_CHANGED, ui::AXEventGenerator::DROPEFFECT_CHANGED, ui::AXEventGenerator::ENABLED_CHANGED, ui::AXEventGenerator::EXPANDED, ui::AXEventGenerator::FLOW_FROM_CHANGED, ui::AXEventGenerator::FLOW_TO_CHANGED, ui::AXEventGenerator::FOCUS_CHANGED, ui::AXEventGenerator::GRABBED_CHANGED, ui::AXEventGenerator::HASPOPUP_CHANGED, ui::AXEventGenerator::HIERARCHICAL_LEVEL_CHANGED, ui::AXEventGenerator::IGNORED_CHANGED, ui::AXEventGenerator::IMAGE_ANNOTATION_CHANGED, ui::AXEventGenerator::INVALID_STATUS_CHANGED, ui::AXEventGenerator::KEY_SHORTCUTS_CHANGED, ui::AXEventGenerator::LABELED_BY_CHANGED, ui::AXEventGenerator::LANGUAGE_CHANGED, ui::AXEventGenerator::LAYOUT_INVALIDATED, ui::AXEventGenerator::LIVE_REGION_CHANGED, ui::AXEventGenerator::LIVE_REGION_CREATED, ui::AXEventGenerator::LIVE_REGION_NODE_CHANGED, ui::AXEventGenerator::LIVE_RELEVANT_CHANGED, ui::AXEventGenerator::LIVE_STATUS_CHANGED, ui::AXEventGenerator::LOAD_COMPLETE, ui::AXEventGenerator::LOAD_START, ui::AXEventGenerator::MENU_ITEM_SELECTED, ui::AXEventGenerator::MULTILINE_STATE_CHANGED, ui::AXEventGenerator::MULTISELECTABLE_STATE_CHANGED, ui::AXEventGenerator::NAME_CHANGED, ui::AXEventGenerator::OBJECT_ATTRIBUTE_CHANGED, ui::AXEventGenerator::OTHER_ATTRIBUTE_CHANGED, ui::AXEventGenerator::PLACEHOLDER_CHANGED, ui::AXEventGenerator::PORTAL_ACTIVATED, ui::AXEventGenerator::POSITION_IN_SET_CHANGED, ui::AXEventGenerator::READONLY_CHANGED, ui::AXEventGenerator::RELATED_NODE_CHANGED, ui::AXEventGenerator::REQUIRED_STATE_CHANGED, ui::AXEventGenerator::ROLE_CHANGED, ui::AXEventGenerator::ROW_COUNT_CHANGED, ui::AXEventGenerator::SCROLL_HORIZONTAL_POSITION_CHANGED, ui::AXEventGenerator::SCROLL_VERTICAL_POSITION_CHANGED, ui::AXEventGenerator::SELECTED_CHANGED, ui::AXEventGenerator::SELECTED_CHILDREN_CHANGED, ui::AXEventGenerator::SET_SIZE_CHANGED, ui::AXEventGenerator::SORT_CHANGED, ui::AXEventGenerator::STATE_CHANGED, ui::AXEventGenerator::SUBTREE_CREATED, ui::AXEventGenerator::TEXT_ATTRIBUTE_CHANGED, ui::AXEventGenerator::VALUE_CHANGED, ui::AXEventGenerator::VALUE_MAX_CHANGED, ui::AXEventGenerator::VALUE_MIN_CHANGED, ui::AXEventGenerator::VALUE_STEP_CHANGED, and ui::AXEventGenerator::WIN_IACCESSIBLE_STATE_CHANGED.

◆ 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}

References ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::has_tree_data, ui::AXNode::kInvalidAXID, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::node_id_to_clear, ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::root_id, and ui::AXTreeUpdateBase< AXNodeData, AXTreeData >::tree_data.

Variable Documentation

◆ g_active_popup_ax_unique_id

std::optional<int32_t> ui::g_active_popup_ax_unique_id
static

◆ g_ax_embedded_object_behavior

◆ g_unique_id_map

◆ kMaxId

const int32_t ui::kMaxId = 100
static

Definition at line 19 of file ax_unique_id_unittest.cc.

Referenced by TEST(), and TEST().

◆ 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.

16 {
17 0x3761326a,
18 0x34b2,
19 0x465a,
20 {0x83, 0x5d, 0x7a, 0x3d, 0x8f, 0x4e, 0xfb, 0x92}};

Referenced by ui::UiaRegistrarWin::UiaRegistrarWin().

◆ 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.

23 {
24 0xcc7eeb32,
25 0x4b62,
26 0x4f4c,
27 {0xaf, 0xf6, 0x1c, 0x2e, 0x57, 0x52, 0xad, 0x8e}};

Referenced by ui::UiaRegistrarWin::UiaRegistrarWin().