chromium/ui/accessibility/platform/test_ax_node_wrapper.cc

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/accessibility/platform/test_ax_node_wrapper.h"

#include <algorithm>
#include <map>
#include <utility>
#include <vector>

#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "ui/accessibility/ax_action_data.h"
#include "ui/accessibility/ax_role_properties.h"
#include "ui/accessibility/ax_selection.h"
#include "ui/accessibility/ax_table_info.h"
#include "ui/accessibility/ax_tree_observer.h"
#include "ui/gfx/geometry/rect_conversions.h"

namespace ui {

namespace {

// A global map from AXNodes to TestAXNodeWrappers.
std::map<AXNodeID, TestAXNodeWrapper*> g_node_id_to_wrapper_map;

// A global coordinate offset.
gfx::Vector2d g_offset;

// A global scale factor.
float g_scale_factor =;

// A global map that stores which node is focused on a determined tree.
//   - If a tree has no node being focused, there shouldn't be any entry on the
//     map associated with such tree, i.e. a pair {tree, nullptr} is invalid.
//   - For testing purposes, assume there is a single node being focused in the
//     entire tree and if such node is deleted, focus is completely lost.
std::map<AXTree*, AXNode*> g_focused_node_in_tree;

// A global indicating the last node which ShowContextMenu was called from.
AXNode* g_node_from_last_show_context_menu;

// A global indicating the last node which accessibility perform action
// default action was called from.
AXNode* g_node_from_last_default_action;

// A global indicating that AXPlatformNodeDelegate objects are web content.
bool g_is_web_content =;

// A map of hit test results - a map from source node ID to destination node
// ID.
std::map<AXNodeID, AXNodeID> g_hit_test_result;

// A simple implementation of AXTreeObserver to catch when AXNodes are
// deleted so we can delete their wrappers.
class TestAXTreeObserver : public AXTreeObserver {};

TestAXTreeObserver g_ax_tree_observer;

}  // namespace

// static
TestAXNodeWrapper* TestAXNodeWrapper::GetOrCreate(AXTree* tree, AXNode* node) {}

// static
void TestAXNodeWrapper::SetGlobalCoordinateOffset(const gfx::Vector2d& offset) {}

// static
const AXNode* TestAXNodeWrapper::GetNodeFromLastShowContextMenu() {}

// static
const AXNode* TestAXNodeWrapper::GetNodeFromLastDefaultAction() {}

// static
void TestAXNodeWrapper::SetNodeFromLastDefaultAction(AXNode* node) {}

// static
std::unique_ptr<base::AutoReset<float>> TestAXNodeWrapper::SetScaleFactor(
    float value) {}

// static
void TestAXNodeWrapper::SetGlobalIsWebContent(bool is_web_content) {}

// static
void TestAXNodeWrapper::SetHitTestResult(AXNodeID src_node_id,
                                         AXNodeID dst_node_id) {}

// static
void TestAXNodeWrapper::ResetGlobalState() {}

TestAXNodeWrapper::~TestAXNodeWrapper() {}

const AXNodeData& TestAXNodeWrapper::GetData() const {}

const AXTreeData& TestAXNodeWrapper::GetTreeData() const {}

const AXSelection TestAXNodeWrapper::GetUnignoredSelection() const {}

AXNodePosition::AXPositionInstance TestAXNodeWrapper::CreatePositionAt(
    int offset,
    ax::mojom::TextAffinity affinity) const {}

AXNodePosition::AXPositionInstance TestAXNodeWrapper::CreateTextPositionAt(
    int offset,
    ax::mojom::TextAffinity affinity) const {}

gfx::NativeViewAccessible TestAXNodeWrapper::GetNativeViewAccessible() {}

gfx::NativeViewAccessible TestAXNodeWrapper::GetParent() const {}

size_t TestAXNodeWrapper::GetChildCount() const {}

gfx::NativeViewAccessible TestAXNodeWrapper::ChildAtIndex(size_t index) const {}

gfx::Rect TestAXNodeWrapper::GetBoundsRect(
    const AXCoordinateSystem coordinate_system,
    const AXClippingBehavior clipping_behavior,
    AXOffscreenResult* offscreen_result) const {}

gfx::Rect TestAXNodeWrapper::GetInnerTextRangeBoundsRect(
    const int start_offset,
    const int end_offset,
    const AXCoordinateSystem coordinate_system,
    const AXClippingBehavior clipping_behavior,
    AXOffscreenResult* offscreen_result) const {}

gfx::Rect TestAXNodeWrapper::GetHypertextRangeBoundsRect(
    const int start_offset,
    const int end_offset,
    const AXCoordinateSystem coordinate_system,
    const AXClippingBehavior clipping_behavior,
    AXOffscreenResult* offscreen_result) const {}

TestAXNodeWrapper* TestAXNodeWrapper::HitTestSyncInternal(int x, int y) {}

gfx::NativeViewAccessible TestAXNodeWrapper::HitTestSync(
    int screen_physical_pixel_x,
    int screen_physical_pixel_y) const {}

gfx::NativeViewAccessible TestAXNodeWrapper::GetFocus() const {}

bool TestAXNodeWrapper::IsMinimized() const {}

bool TestAXNodeWrapper::IsWebContent() const {}

bool TestAXNodeWrapper::IsReadOnlySupported() const {}

bool TestAXNodeWrapper::IsReadOnlyOrDisabled() const {}

// Walk the AXTree and ensure that all wrappers are created
void TestAXNodeWrapper::BuildAllWrappers(AXTree* tree, AXNode* node) {}

void TestAXNodeWrapper::ResetNativeEventTarget() {}

AXPlatformNode* TestAXNodeWrapper::GetFromNodeID(int32_t id) {}

AXPlatformNode* TestAXNodeWrapper::GetFromTreeIDAndNodeID(
    const AXTreeID& ax_tree_id,
    int32_t id) {}

std::optional<size_t> TestAXNodeWrapper::GetIndexInParent() const {}

void TestAXNodeWrapper::ReplaceIntAttribute(int32_t node_id,
                                            ax::mojom::IntAttribute attribute,
                                            int32_t value) {}

void TestAXNodeWrapper::ReplaceFloatAttribute(
    ax::mojom::FloatAttribute attribute,
    float value) {}

void TestAXNodeWrapper::ReplaceBoolAttribute(ax::mojom::BoolAttribute attribute,
                                             bool value) {}

void TestAXNodeWrapper::ReplaceStringAttribute(
    ax::mojom::StringAttribute attribute,
    std::string value) {}

void TestAXNodeWrapper::ReplaceTreeDataTextSelection(int32_t anchor_node_id,
                                                     int32_t anchor_offset,
                                                     int32_t focus_node_id,
                                                     int32_t focus_offset) {}

std::optional<int> TestAXNodeWrapper::GetTableRowCount() const {}

std::optional<int> TestAXNodeWrapper::GetTableColCount() const {}

std::optional<int> TestAXNodeWrapper::GetTableAriaRowCount() const {}

std::optional<int> TestAXNodeWrapper::GetTableAriaColCount() const {}

std::optional<int> TestAXNodeWrapper::GetTableCellCount() const {}

std::vector<AXNodeID> TestAXNodeWrapper::GetColHeaderNodeIds() const {}

std::vector<AXNodeID> TestAXNodeWrapper::GetColHeaderNodeIds(
    int col_index) const {}

std::vector<AXNodeID> TestAXNodeWrapper::GetRowHeaderNodeIds() const {}

std::vector<AXNodeID> TestAXNodeWrapper::GetRowHeaderNodeIds(
    int row_index) const {}

bool TestAXNodeWrapper::IsTableRow() const {}

std::optional<int> TestAXNodeWrapper::GetTableRowRowIndex() const {}

bool TestAXNodeWrapper::IsTableCellOrHeader() const {}

std::optional<int> TestAXNodeWrapper::GetTableCellIndex() const {}

std::optional<int> TestAXNodeWrapper::GetTableCellColIndex() const {}

std::optional<int> TestAXNodeWrapper::GetTableCellRowIndex() const {}

std::optional<int> TestAXNodeWrapper::GetTableCellColSpan() const {}

std::optional<int> TestAXNodeWrapper::GetTableCellRowSpan() const {}

std::optional<int> TestAXNodeWrapper::GetTableCellAriaColIndex() const {}

std::optional<int> TestAXNodeWrapper::GetTableCellAriaRowIndex() const {}

std::optional<int32_t> TestAXNodeWrapper::GetCellId(int row_index,
                                                    int col_index) const {}
std::optional<int32_t> TestAXNodeWrapper::GetCellIdAriaCoords(
    int aria_row_index,
    int aria_col_index) const {}

gfx::AcceleratedWidget
TestAXNodeWrapper::GetTargetForNativeAccessibilityEvent() {}

std::optional<int32_t> TestAXNodeWrapper::CellIndexToId(int cell_index) const {}

bool TestAXNodeWrapper::IsCellOrHeaderOfAriaGrid() const {}

bool TestAXNodeWrapper::AccessibilityPerformAction(const AXActionData& data) {}

std::u16string TestAXNodeWrapper::GetLocalizedRoleDescriptionForUnlabeledImage()
    const {}

std::u16string TestAXNodeWrapper::GetLocalizedStringForLandmarkType() const {}

std::u16string TestAXNodeWrapper::GetLocalizedStringForRoleDescription() const {}

std::u16string TestAXNodeWrapper::GetLocalizedStringForImageAnnotationStatus(
    ax::mojom::ImageAnnotationStatus status) const {}

std::u16string TestAXNodeWrapper::GetStyleNameAttributeAsLocalizedString()
    const {}

bool TestAXNodeWrapper::ShouldIgnoreHoveredStateForTesting() {}

bool TestAXNodeWrapper::HasVisibleCaretOrSelection() const {}

std::vector<AXPlatformNode*>
TestAXNodeWrapper::GetSourceNodesForReverseRelations(
    ax::mojom::IntAttribute attr) {}

std::vector<AXPlatformNode*>
TestAXNodeWrapper::GetSourceNodesForReverseRelations(
    ax::mojom::IntListAttribute attr) {}

AXPlatformNodeId TestAXNodeWrapper::GetUniqueId() const {}

TestAXNodeWrapper::TestAXNodeWrapper(AXTree* tree, AXNode* node)
    :{}

bool TestAXNodeWrapper::IsOrderedSetItem() const {}

bool TestAXNodeWrapper::IsOrderedSet() const {}

std::optional<int> TestAXNodeWrapper::GetPosInSet() const {}

std::optional<int> TestAXNodeWrapper::GetSetSize() const {}

SkColor TestAXNodeWrapper::GetColor() const {}

SkColor TestAXNodeWrapper::GetBackgroundColor() const {}

gfx::RectF TestAXNodeWrapper::GetLocation() const {}

size_t TestAXNodeWrapper::InternalChildCount() const {}

TestAXNodeWrapper* TestAXNodeWrapper::InternalGetChild(size_t index) const {}

const std::vector<gfx::NativeViewAccessible>
TestAXNodeWrapper::GetUIADirectChildrenInRange(AXPlatformNodeDelegate* start,
                                               AXPlatformNodeDelegate* end) {}

// static
// Needs to stay in sync with AXPlatformNodeWin::ShouldHideChildrenForUIA.
bool TestAXNodeWrapper::ShouldHideChildrenForUIA(const AXNode* node) {}

gfx::RectF TestAXNodeWrapper::GetInlineTextRect(const int start_offset,
                                                const int end_offset) const {}

bool TestAXNodeWrapper::Intersects(gfx::RectF rect1, gfx::RectF rect2) const {}

AXOffscreenResult TestAXNodeWrapper::DetermineOffscreenResult(
    gfx::RectF bounds) const {}

}  // namespace ui