1 // Copyright 2020 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef UI_ACCESSIBILITY_TEST_AX_NODE_HELPER_H_
6 #define UI_ACCESSIBILITY_TEST_AX_NODE_HELPER_H_
7 
8 #include "ui/accessibility/ax_clipping_behavior.h"
9 #include "ui/accessibility/ax_coordinate_system.h"
10 #include "ui/accessibility/ax_node.h"
11 #include "ui/accessibility/ax_offscreen_result.h"
12 #include "ui/accessibility/ax_tree.h"
13 
14 namespace ui {
15 
16 // For testing, a TestAXNodeHelper wraps an AXNode. This is a simple
17 // version of TestAXNodeWrapper.
18 class TestAXNodeHelper {
19  public:
20   // Create TestAXNodeHelper instances on-demand from an AXTree and AXNode.
21   static TestAXNodeHelper* GetOrCreate(AXTree* tree, AXNode* node);
22   ~TestAXNodeHelper();
23 
24   gfx::Rect GetBoundsRect(const AXCoordinateSystem coordinate_system,
25                           const AXClippingBehavior clipping_behavior,
26                           AXOffscreenResult* offscreen_result) const;
27   gfx::Rect GetInnerTextRangeBoundsRect(
28       const int start_offset,
29       const int end_offset,
30       const AXCoordinateSystem coordinate_system,
31       const AXClippingBehavior clipping_behavior,
32       AXOffscreenResult* offscreen_result) const;
33 
34  private:
35   TestAXNodeHelper(AXTree* tree, AXNode* node);
36   int InternalChildCount() const;
37   TestAXNodeHelper* InternalGetChild(int index) const;
38   const AXNodeData& GetData() const;
39   gfx::RectF GetLocation() const;
40   gfx::RectF GetInlineTextRect(const int start_offset,
41                                const int end_offset) const;
42   AXOffscreenResult DetermineOffscreenResult(gfx::RectF bounds) const;
43 
44   AXTree* tree_;
45   AXNode* node_;
46 };
47 
48 }  // namespace ui
49 
50 #endif  // UI_ACCESSIBILITY_TEST_AX_NODE_HELPER_H_
51