test_ax_node_helper.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. #ifndef UI_ACCESSIBILITY_TEST_AX_NODE_HELPER_H_
  5. #define UI_ACCESSIBILITY_TEST_AX_NODE_HELPER_H_
  6. #include "base/memory/raw_ptr.h"
  7. #include "ui/accessibility/ax_clipping_behavior.h"
  8. #include "ui/accessibility/ax_coordinate_system.h"
  9. #include "ui/accessibility/ax_node.h"
  10. #include "ui/accessibility/ax_offscreen_result.h"
  11. #include "ui/accessibility/ax_tree.h"
  12. namespace ui {
  13. // For testing, a TestAXNodeHelper wraps an AXNode. This is a simple
  14. // version of TestAXNodeWrapper.
  15. class TestAXNodeHelper {
  16. public:
  17. // Create TestAXNodeHelper instances on-demand from an AXTree and AXNode.
  18. static TestAXNodeHelper* GetOrCreate(AXTree* tree, AXNode* node);
  19. ~TestAXNodeHelper();
  20. gfx::Rect GetBoundsRect(const AXCoordinateSystem coordinate_system,
  21. const AXClippingBehavior clipping_behavior,
  22. AXOffscreenResult* offscreen_result) const;
  23. gfx::Rect GetInnerTextRangeBoundsRect(
  24. const int start_offset,
  25. const int end_offset,
  26. const AXCoordinateSystem coordinate_system,
  27. const AXClippingBehavior clipping_behavior,
  28. AXOffscreenResult* offscreen_result) const;
  29. private:
  30. TestAXNodeHelper(AXTree* tree, AXNode* node);
  31. int InternalChildCount() const;
  32. TestAXNodeHelper* InternalGetChild(int index) const;
  33. const AXNodeData& GetData() const;
  34. gfx::RectF GetLocation() const;
  35. gfx::RectF GetInlineTextRect(const int start_offset,
  36. const int end_offset) const;
  37. // Helper for determining if the two rects, including empty rects, intersect
  38. // each other.
  39. bool Intersects(gfx::RectF rect1, gfx::RectF rect2) const;
  40. // Determine the offscreen status of a particular element given its bounds.
  41. AXOffscreenResult DetermineOffscreenResult(gfx::RectF bounds) const;
  42. raw_ptr<AXTree> tree_;
  43. raw_ptr<AXNode> node_;
  44. };
  45. } // namespace ui
  46. #endif // UI_ACCESSIBILITY_TEST_AX_NODE_HELPER_H_