Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
ui::TestAXNodeHelper Class Reference

#include <test_ax_node_helper.h>

Public Member Functions

 ~TestAXNodeHelper ()
 
gfx::Rect GetBoundsRect (const AXCoordinateSystem coordinate_system, const AXClippingBehavior clipping_behavior, AXOffscreenResult *offscreen_result) const
 
gfx::Rect GetInnerTextRangeBoundsRect (const int start_offset, const int end_offset, const AXCoordinateSystem coordinate_system, const AXClippingBehavior clipping_behavior, AXOffscreenResult *offscreen_result) const
 

Static Public Member Functions

static TestAXNodeHelperGetOrCreate (AXTree *tree, AXNode *node)
 

Detailed Description

Definition at line 18 of file test_ax_node_helper.h.

Constructor & Destructor Documentation

◆ ~TestAXNodeHelper()

ui::TestAXNodeHelper::~TestAXNodeHelper ( )
default

Member Function Documentation

◆ GetBoundsRect()

gfx::Rect ui::TestAXNodeHelper::GetBoundsRect ( const AXCoordinateSystem  coordinate_system,
const AXClippingBehavior  clipping_behavior,
AXOffscreenResult offscreen_result 
) const

Definition at line 62 of file test_ax_node_helper.cc.

65 {
66 switch (coordinate_system) {
68 // For unit testing purposes, assume a device scale factor of 1 and fall
69 // through.
71 // We could optionally add clipping here if ever needed.
72 gfx::RectF bounds = GetLocation();
73
74 // For test behavior only, for bounds that are offscreen we currently do
75 // not apply clipping to the bounds but we still return the offscreen
76 // status.
77 if (offscreen_result) {
78 *offscreen_result = DetermineOffscreenResult(bounds);
79 }
80
81 return gfx::ToEnclosingRect(bounds);
82 }
86 return gfx::Rect();
87 }
88}
Optional< SkRect > bounds
Definition SkRecords.h:189
Rect ToEnclosingRect(const RectF &r)
#define BASE_UNREACHABLE()
Definition logging.h:69

◆ GetInnerTextRangeBoundsRect()

gfx::Rect ui::TestAXNodeHelper::GetInnerTextRangeBoundsRect ( const int  start_offset,
const int  end_offset,
const AXCoordinateSystem  coordinate_system,
const AXClippingBehavior  clipping_behavior,
AXOffscreenResult offscreen_result 
) const

Definition at line 90 of file test_ax_node_helper.cc.

95 {
96 switch (coordinate_system) {
98 // For unit testing purposes, assume a device scale factor of 1 and fall
99 // through.
101 gfx::RectF bounds = GetLocation();
102 // This implementation currently only deals with text node that has role
103 // kInlineTextBox and kStaticText.
104 // For test purposes, assume node with kStaticText always has a single
105 // child with role kInlineTextBox.
106 if (GetData().role == ax::mojom::Role::kInlineTextBox) {
107 bounds = GetInlineTextRect(start_offset, end_offset);
108 } else if (GetData().role == ax::mojom::Role::kStaticText &&
109 InternalChildCount() > 0) {
110 TestAXNodeHelper* child = InternalGetChild(0);
111 if (child != nullptr &&
112 child->GetData().role == ax::mojom::Role::kInlineTextBox) {
113 bounds = child->GetInlineTextRect(start_offset, end_offset);
114 }
115 }
116
117 // For test behavior only, for bounds that are offscreen we currently do
118 // not apply clipping to the bounds but we still return the offscreen
119 // status.
120 if (offscreen_result) {
121 *offscreen_result = DetermineOffscreenResult(bounds);
122 }
123
124 return gfx::ToEnclosingRect(bounds);
125 }
129 return gfx::Rect();
130 }
131}

◆ GetOrCreate()

TestAXNodeHelper * ui::TestAXNodeHelper::GetOrCreate ( AXTree tree,
AXNode node 
)
static

Definition at line 43 of file test_ax_node_helper.cc.

43 {
44 if (!tree || !node)
45 return nullptr;
46
47 if (!tree->HasObserver(&g_ax_tree_observer))
48 tree->AddObserver(&g_ax_tree_observer);
49 auto iter = g_node_id_to_helper_map.find(node->id());
50 if (iter != g_node_id_to_helper_map.end())
51 return iter->second;
52 TestAXNodeHelper* helper = new TestAXNodeHelper(tree, node);
53 g_node_id_to_helper_map[node->id()] = helper;
54 return helper;
55}

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