7#include "gtest/gtest.h"
15void MakeStaticText(AXNodeData* node,
int id,
const std::string&
text) {
21void MakeGroup(AXNodeData* node,
int id, std::vector<int> child_ids) {
24 node->child_ids = child_ids;
27void SetIsInvisible(AXTree* tree,
int id,
bool invisible) {
30 update.nodes[0] = tree->GetFromId(
id)->data();
41 update.nodes[0] = tree->GetFromId(
id)->data();
42 update.nodes[0].role = role;
48TEST(AXPlatformNodeBaseTest, GetHypertext) {
61 update.nodes[0].child_ids = {2, 3, 4};
63 MakeStaticText(&
update.nodes[1], 2,
"text1");
64 MakeStaticText(&
update.nodes[2], 3,
"text2");
65 MakeStaticText(&
update.nodes[3], 4,
"text3");
91TEST(AXPlatformNodeBaseTest, GetHypertextIgnoredContainerSiblings) {
107 update.nodes[0].child_ids = {2, 4, 6};
110 update.nodes[1].child_ids = {3};
113 MakeStaticText(&
update.nodes[2], 3,
"text1");
116 update.nodes[3].child_ids = {5};
119 MakeStaticText(&
update.nodes[4], 5,
"text2");
122 update.nodes[5].child_ids = {7};
125 MakeStaticText(&
update.nodes[6], 7,
"text3");
156TEST(AXPlatformNodeBaseTest, InnerTextIgnoresInvisibleAndIgnored) {
162 MakeStaticText(&
update.nodes[1], 2,
"a");
163 MakeStaticText(&
update.nodes[2], 3,
"b");
165 MakeStaticText(&
update.nodes[4], 5,
"d");
166 MakeStaticText(&
update.nodes[5], 6,
"e");
168 MakeGroup(&
update.nodes[3], 4, {5, 6});
169 MakeGroup(&
update.nodes[0], 1, {2, 3, 4});
185 SetIsInvisible(&tree, 2,
true);
188 SetIsInvisible(&tree, 2,
false);
201 SetIsInvisible(&tree, 4,
true);
209TEST(AXPlatformNodeBaseTest, TestSelectedChildren) {
229 update.nodes = {root_data, item_1_data, item_2_data};
235 int num =
root->GetSelectionCount();
241 EXPECT_EQ(
nullptr,
root->GetSelectedItem(1));
244TEST(AXPlatformNodeBaseTest, TestSelectedChildrenWithGroup) {
284 update.nodes = {root_data, group_1_data, group_2_data, item_1_data,
285 item_2_data, item_3_data, item_4_data};
291 int num =
root->GetSelectionCount();
306 EXPECT_EQ(second_group_child,
310TEST(AXPlatformNodeBaseTest, TestSelectedChildrenMixed) {
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};
379 int num =
root->GetSelectionCount();
405TEST(AXPlatformNodeBaseTest, CompareTo) {
467 update.nodes = {node1, node2, node3, node4, node5,
468 node6, node7, node8, node9, node10};
497 EXPECT_EQ(std::nullopt, n1->CompareTo(detached_node));
502 std::vector<AXPlatformNodeBase*> preorder_tree_nodes = {n1, n2, n3, n4, n5,
503 n6, n7, n8, n9, n10};
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)
514 EXPECT_NE(std::nullopt, lhs->CompareTo(*rhs));
515 int actual_result = 0;
516 if (lhs->CompareTo(*rhs) < 0)
518 else if (lhs->CompareTo(*rhs) > 0)
521 SCOPED_TRACE(testing::Message()
524 <<
", lhs->CompareTo(*rhs)={actual:"
528 EXPECT_EQ(expected_result, actual_result);
static TestAXNodeWrapper * GetOrCreate(AXTree *tree, AXNode *node)
AXPlatformNode * ax_platform_node() const
std::u16string UTF8ToUTF16(std::string src)
std::string NumberToString(int32_t number)
UnimplementedNativeViewAccessible * NativeViewAccessible
static constexpr AXMode kAXModeComplete(AXMode::kNativeAPIs|AXMode::kWebContents|AXMode::kInlineTextBoxes|AXMode::kScreenReader|AXMode::kHTML)
AXTreeUpdateBase< AXNodeData, AXTreeData > AXTreeUpdate
TEST(AXEnumUtilTest, Event)
void AddState(ax::mojom::State state)
std::vector< int32_t > child_ids
void AddBoolAttribute(ax::mojom::BoolAttribute attribute, bool value)